Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide more custom semantic token types/modfiers #2106

Open
Techatrix opened this issue Dec 10, 2024 · 1 comment
Open

provide more custom semantic token types/modfiers #2106

Techatrix opened this issue Dec 10, 2024 · 1 comment
Labels
enhancement New feature or request priority:low Low priority item

Comments

@Techatrix
Copy link
Member

LSP semantic tokens offer a predefined set of semantic token types and semantic token modifiers. ZLS is currently emitting mostly standard token types with relatively few exceptions. The problem is that the existing token types are not able to accurately represent the language features of Zig which hurts the advantages that semantic highlighting can offer over syntactic highlighting.

Custom semantic tokens could enable ZLS to eventually explore new features like the following:

  • differentiate between mutable and non-mutable values Improve Semantic Token Type ziglang/vscode-zig#213
  • differentiate between different "kinds" of builtin functions Different semantic highlighting for builtin functions #2104
  • highlight code that may invoke safety-protected Undefined Behavior (e.g. highlight @enumFromInt for non-exhaustive enums but not for exhaustive enums, @intCast but not @truncate, + but not +|, etc.)
  • highlight inline functions at the callsite
  • highlight escape sequences inside string literals
  • highlight format specifiers like "{s}"

This issue encompasses two important tasks:

  • specify a set of token types and token modifiers that are tailored to Zig
  • investigate how various editors deal with custom semantic tokens

As far as I can tell, rust-analyzer uses a lot of non standard tokens. Their approach may serve as good source of inspiration.

@Techatrix Techatrix added enhancement New feature or request priority:low Low priority item labels Dec 10, 2024
@arrufat
Copy link

arrufat commented Dec 11, 2024

  • investigate how various editors deal with custom semantic tokens

Regarding this part, I have experience using @kakoune-lsp, which provides a straightforward approach. Here's my configuration, where face fields are faces defined in the Kakoune editor, which can be set to any combination of color/bold/italic/underline/double underline/curly underline, as shown here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:low Low priority item
Projects
None yet
Development

No branches or pull requests

2 participants