Open Av1d1ty opened 4 months ago
Above Terminal is NeoVim 0.10.0, Bottom Terminal is Neovim 0.9.5
In case this is hard to see, the escape characters are highlighted except with ZLS on NeoVim 0.10.0. Everything else was as expected.
I tried out a few of the default colorschemes in NeoVim 0.10.0 but that didn't help.
I did not observe any changes when enabling the zig.vim
extension.
So it seems like something is going on with NeoVim 0.10.0... :thinking:
Also special characters are displayed correctly in Lua files with lua-ls active.
It seems like neovim's semantic token highlighting are overriding tree-sitter's highlight's for the escaped characters. Adding the following to my config disabled semantic highlighting for zig string tokens, and appears to fix the issue:
vim.api.nvim_set_hl(0, '@lsp.type.string.zig', {})
I'm not sure what a more permanent/ "out of the box" fix would be, as it seems that semantic token highlights have a higher priority than tree-sitter's by default.
The same thing happens in vscode when semantic_tokens
is set to full
instead of partial
, maybe other editors with grammar based highlighting should also use partial
?
Perhaps it is more reasonable to assume that the editor already provides syntax based highlighting for Zig code? Then we could make partial
the default which also fixes this issue.
Can confirm that setting semantic tokens to "partial" does fix the issue, but at the same time highlighting changes in places where I prefer it would not
Semantic tokens set to "full"
Semantic tokens set to "partial"
As you can see, function parameters are no longer highlighted distinctly in function body.
Also, on a side note, Mason tells me that default value for semantic tokens in "partial", while in fact it is set to "full"
Side note 2: Mason shows config names in camelCase, while in fact they need to be set in snake_case in my config files. Not sure if it is an actual issue. Maybe I lack understanding about how Mason and configs work for language servers.
Mason's package.yaml for ZLS uses vscode-zig's package.json
to provide information about config options. This should not be done because vscode-zig options don't exactly match what ZLS uses. I will look into resolving that.
Can confirm that setting semantic tokens to "partial" does fix the issue, but at the same time highlighting changes in places where I prefer it would not
This should be fixed by 2e5a2a5959c0ba645fd6bfbf93dc467c32458465.
I used folke/tokyonight.nvim and set semantic_tokens
to partial
. Here is how it changed:
Awesome, thanks!
Zig Version
0.12.1
Zig Language Server Version
0.13.0, 0.12.0
Client / Code Editor / Extensions
nvim 0.10, lspconfig
Steps to Reproduce and Observed Behavior
Open file with a special character like \n or \t in a string literal. See that all characters have the same color.
Expected Behavior
Special characters highlighted differently
Image above shows what it looks like when ZLS is turned off.
Relevant log output
No response