Skip to content

Only advertise semanticTokens if there's a handler#640

Merged
fendor merged 1 commit into
haskell:masterfrom
9999years:wiggles/lzkz
May 16, 2026
Merged

Only advertise semanticTokens if there's a handler#640
fendor merged 1 commit into
haskell:masterfrom
9999years:wiggles/lzkz

Conversation

@9999years
Copy link
Copy Markdown
Contributor

Neovim 0.12 and above will make semanticTokens requests on every cursor movement. Currently, the lsp library advertises semanticTokens capabilities, even if the LSP server implemented with this library doesn't a handler. This means that every time I move my cursor I get a blocking error in my editor, making it essentially unusable!

Let's only advertise the capability if there's a handler registered.

Here's a workaround in my Neovim config:

vim.lsp.config("hls", {
  cmd = { "static-ls" },

  on_init = function(client)
    -- static-ls (via the `lsp` Haskell library) falsely advertises
    -- semanticTokensProvider but registers no handler, producing a
    -- "no handler for: textDocument/semanticTokens/full" message on
    -- every cursor move. Strip it.
    client.server_capabilities.semanticTokensProvider = nil
  end,
})

Neovim 0.12 and above will make `semanticTokens` requests on every
cursor movement. Currently, the `lsp` library advertises
`semanticTokens` capabilities, even if the LSP server implemented with
this library doesn't a handler. This means that every time I move my
cursor I get a blocking error in my editor, making it essentially
unusable!

Let's only advertise the capability if there's a handler registered.

Here's a workaround in my Neovim config:

```
vim.lsp.config("hls", {
  cmd = { "static-ls" },

  on_init = function(client)
    -- static-ls (via the `lsp` Haskell library) falsely advertises
    -- semanticTokensProvider but registers no handler, producing a
    -- "no handler for: textDocument/semanticTokens/full" message on
    -- every cursor move. Strip it.
    client.server_capabilities.semanticTokensProvider = nil
  end,
})
```
josephsumabat pushed a commit to josephsumabat/static-ls that referenced this pull request May 15, 2026
`lsp` falsely advertises `semanticTokens` capabilities, regardless of
what we support. Register some no-op handlers so that clients which
trust the LSP server don't crash out.

See: haskell/lsp#640
Copy link
Copy Markdown
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@fendor fendor enabled auto-merge (squash) May 16, 2026 08:44
@fendor fendor merged commit c9a2cad into haskell:master May 16, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants