diff --git a/internal/lsp/server.go b/internal/lsp/server.go index 4edac704..4f16cb47 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -2469,6 +2469,18 @@ func (l *LanguageServer) handleInitialize( Filters: []types.FileOperationFilter{regoFilter}, }, }, + WorkspaceFolders: types.WorkspaceFoldersServerCapabilities{ + // NOTE(anders): The language server protocol doesn't go into detail about what this is meant to + // entail, and there's nothing else in the request/response payloads that carry workspace folder + // information. The best source I've found on the this topic is this example repo from VS Code, + // where they have the client start one instance of the server per workspace folder: + // https://github.com/microsoft/vscode-extension-samples/tree/main/lsp-multi-server-sample + // That seems like a reasonable approach to take, and means we won't have to deal with workspace + // folders throughout the rest of the codebase. But the question then is — what is the point of + // this capability, and what does it mean to say we support it? Clearly we don't in the server as + // *there is no way* to support it here. + Supported: true, + }, }, InlayHintProvider: types.InlayHintOptions{ ResolveProvider: false, diff --git a/internal/lsp/types/types.go b/internal/lsp/types/types.go index e127bd29..02f4b320 100644 --- a/internal/lsp/types/types.go +++ b/internal/lsp/types/types.go @@ -40,7 +40,7 @@ type InitializeParams struct { RootPath string `json:"rootPath"` RootURI string `json:"rootUri"` Trace string `json:"trace"` - WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders"` + WorkspaceFolders *[]WorkspaceFolder `json:"workspaceFolders"` Capabilities ClientCapabilities `json:"capabilities"` ProcessID int `json:"processId"` } @@ -175,8 +175,13 @@ type CompletionItemLabelDetails struct { Detail string `json:"detail"` } +type WorkspaceFoldersServerCapabilities struct { + Supported bool `json:"supported"` +} + type WorkspaceOptions struct { - FileOperations FileOperationsServerCapabilities `json:"fileOperations"` + FileOperations FileOperationsServerCapabilities `json:"fileOperations"` + WorkspaceFolders WorkspaceFoldersServerCapabilities `json:"workspaceFolders"` } type CodeActionOptions struct {