diff --git a/package.json b/package.json index 1597397e..f15d9139 100644 --- a/package.json +++ b/package.json @@ -158,6 +158,12 @@ "default": "", "description": "Manually set a language server executable. Can be something on the $PATH or a path to an executable itself. Works with ~, ${HOME} and ${workspaceFolder}." }, + "haskell.ignoreStandalone": { + "scope": "resource", + "type": "boolean", + "default": false, + "description": "Don't spawn language servers for stand-alone files (i.e. files that don't belong to any folder)" + }, "haskell.updateBehavior": { "scope": "machine", "type": "string", diff --git a/src/extension.ts b/src/extension.ts index e56caa81..4ce7131e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -133,8 +133,9 @@ async function activeServer(context: ExtensionContext, document: TextDocument) { } async function activateServerForFolder(context: ExtensionContext, uri: Uri, folder?: WorkspaceFolder) { + const ignoreStandalone = workspace.getConfiguration('haskell').ignoreStandalone; const clientsKey = folder ? folder.uri.toString() : uri.toString(); - + if (!folder && ignoreStandalone) return; // If the client already has an LSP server for this uri/folder, then don't start a new one. if (clients.has(clientsKey)) { return;