Skip to content
Merged
Changes from all commits
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
16 changes: 11 additions & 5 deletions lsp/src/Language/LSP/Server/Processing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,18 @@ inferServerCapabilities _clientCaps o h =
Just cmds -> ExecuteCommandOptions clientInitiatedProgress cmds
Nothing -> error "executeCommandCommands needs to be set if a executeCommandHandler is set"

-- Always provide the default legend
-- Only advertise semantic tokens if the server has registered a handler for
-- at least one of the semantic-token request methods. Otherwise clients that
-- honor server capabilities (e.g. Neovim's built-in LSP client) will fire
-- requests we can't answer, producing spurious "no handler for" errors.
-- TODO: allow user-provided legend via 'Options', or at least user-provided types
semanticTokensProvider =
Just $
InL $
SemanticTokensOptions clientInitiatedProgress defaultSemanticTokensLegend semanticTokenRangeProvider semanticTokenFullProvider
semanticTokensProvider
| supported_b SMethod_TextDocumentSemanticTokensFull
|| supported_b SMethod_TextDocumentSemanticTokensRange =
Just $
InL $
SemanticTokensOptions clientInitiatedProgress defaultSemanticTokensLegend semanticTokenRangeProvider semanticTokenFullProvider
| otherwise = Nothing
semanticTokenRangeProvider
| supported_b SMethod_TextDocumentSemanticTokensRange = Just $ InL True
| otherwise = Nothing
Expand Down
Loading