zls icon indicating copy to clipboard operation
zls copied to clipboard

Deprecate the 'semantic_tokens' config option in favor of 'augmentsSyntaxTokens'

Open Techatrix opened this issue 7 months ago • 1 comments

The augmentsSyntaxTokens client capability can be used to indicate that the client is going to combine existing syntax tokens with the semantic tokens of the server. This can not only reduce the amount of data that is transferred over the protocol but can also lead to better highlighting as syntax tokens often more accurately distinguish between different language constructs on the syntax level. An example would be keywords where the LSP protocol has a single standard token type compared to syntax highlighting where different keywords are often differentiated between based on their purpose.

The semantic_tokens config had been added for this purpose. The partial option is used to prevent LSP semantic tokens to override existing syntax highlighting of the editor. The benefit of the client capability is that this decision is automatically made by supported editors instead of relying on user to select the right configuration.

The following editors should be unaffected:

  • VS Code: enables partial by default
  • LSP4IJ (JetBrains): does not enable augmentsSyntaxTokens
  • Helix: does not use semantic tokens
  • Zed: does not use semantic tokens
  • Kate: does not enable augmentsSyntaxTokens
  • Eglot (Emacs): TODO
  • lsp-mode (Emacs): TODO

The following editors are affected:

Sublime Text

Requires the semantic_highlighting config option to be enabled.

Before: sublime-text-before After: sublime-text-after

The new output more closely matches the result when disabling semantic highlighting:

sublime-text-none

Neovim

Tested with tokyonight.nvim

Before: neovim-before

After: neovim-after

The zig.vim plugin maps the var, const, comptime and threadlocal keywords to Function which doesn't seem right.

The changes in Neovim should be investigated further before merging this PR.

Techatrix avatar May 31 '25 07:05 Techatrix

@Techatrix I suggest thzt yiu create an issue on Lsp4ij to take care of this capability and if you could explain me how to implement it. Thanks!

angelozerr avatar Jun 06 '25 14:06 angelozerr