Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@
"Prefer a multiple component session, if the build tool supports it. At the moment, only `cabal` supports multiple components session loading. If the `cabal` version does not support loading multiple components at once, we gracefully fall back to \"singleComponent\" mode."
]
},
"haskell.supportCabalFiles": {
"scope": "resource",
"default": true,
"type": "boolean",
"description": "Enable Language Server support for `.cabal` files. Requires Haskell Language Server version >= 2.0.0.0."
},
"haskell.maxCompletions": {
"scope": "resource",
"default": 40,
Expand Down
20 changes: 15 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
args = args.concat(extraArgs.split(' '));
}

const cabalFileSupport: boolean = workspace.getConfiguration('haskell', uri).supportCabalFiles;
logger.info(`Support for '.cabal' files enabled: ${cabalFileSupport ? 'yes' : 'no'}`);

// If we're operating on a standalone file (i.e. not in a folder) then we need
// to launch the server in a reasonable current directory. Otherwise the cradle
// guessing logic in hie-bios will be wrong!
Expand Down Expand Up @@ -253,14 +256,21 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold

const pat = folder ? `${folder.uri.fsPath}/**/*` : '**/*';
logger.log(`document selector patten: ${pat}`);


const cabalDocumentSelector = cabalFileSupport ? [{ scheme: 'file', language: 'cabal', pattern: pat }] : [];
const haskellDocumentSelector = [
{ scheme: 'file', language: 'haskell', pattern: pat },
{ scheme: 'file', language: 'literate haskell', pattern: pat },
];

const clientOptions: LanguageClientOptions = {
// Use the document selector to only notify the LSP on files inside the folder
// path for the specific workspace.
documentSelector: [
{ scheme: 'file', language: 'haskell', pattern: pat },
{ scheme: 'file', language: 'literate haskell', pattern: pat },
{ scheme: 'file', language: 'cabal', pattern: pat },
],
documentSelector:
[ ... haskellDocumentSelector
, ... cabalDocumentSelector
],
synchronize: {
// Synchronize the setting section 'haskell' to the server.
configurationSection: 'haskell',
Expand Down