From 960b486e8cfe4fd5165be4dd200457c7e5b90979 Mon Sep 17 00:00:00 2001 From: Michael Angelo Rivera <55844504+michaelangeloio@users.noreply.github.com> Date: Tue, 9 Jan 2024 11:28:12 -0500 Subject: [PATCH] feat: LSP now supports workspace folders (#127) --- server/src/server.ts | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/server/src/server.ts b/server/src/server.ts index 40f58fa..f8af0e5 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -19,44 +19,27 @@ const connection = createConnection(ProposedFeatures.all) const documents: TextDocuments = new TextDocuments(TextDocument) let hasConfigurationCapability = false let hasWorkspaceFolderCapability = false -// use if needed later -// let hasDiagnosticRelatedInformationCapability = false - -let rootUri: string | undefined | null connection.onInitialize((params: InitializeParams) => { const capabilities = params.capabilities + // Does the client support the `workspace/configuration` request? + // If not, we fall back using global settings. hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration) hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders) - // use if needed later - // hasDiagnosticRelatedInformationCapability = !!( - // capabilities.textDocument && - // capabilities.textDocument.publishDiagnostics && - // capabilities.textDocument.publishDiagnostics.relatedInformation - // ) const result: InitializeResult = { capabilities: { textDocumentSync: TextDocumentSyncKind.Incremental } } - if (params?.workspaceFolders && params.workspaceFolders.length > 1) { - throw new Error('This extension only supports one workspace folder at this time') - } if (hasWorkspaceFolderCapability) { result.capabilities.workspace = { workspaceFolders: { - supported: false + supported: true } } } - if (!hasWorkspaceFolderCapability) { - rootUri = params.rootUri - } else { - rootUri = params?.workspaceFolders?.[0]?.uri - } - return result })