-
-
Notifications
You must be signed in to change notification settings - Fork 298
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
Special characters not highlighted in strings #1928
Comments
Above Terminal is NeoVim 0.10.0, Bottom Terminal is Neovim 0.9.5 With ZLSWithout ZLSIn case this is hard to see, the escape characters are highlighted except with ZLS on NeoVim 0.10.0. Everything else was as expected. So it seems like something is going on with NeoVim 0.10.0... 🤔 The `init.lua` being usedlocal vim = vim
local Plug = vim.fn['plug#']
vim.call('plug#begin')
Plug('neovim/nvim-lspconfig') -- https://github.com/neovim/nvim-lspconfig
-- Plug('ziglang/zig.vim') -- https://github.com/ziglang/zig.vim
vim.call('plug#end')
-- I disabled ZLS by removing everything below here
local lspconfig = require('lspconfig')
lspconfig.zls.setup {
cmd = { '/home/techatrix/repos/zls/zig-out/bin/zls' },
settings = {
zls = {
zig_exe_path = '/nix/store/s3nq31mhm8gxkq691p5w6q61ficw1hvr-zig-0.13.0/bin/zig',
}
}
} |
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 |
Perhaps it is more reasonable to assume that the editor already provides syntax based highlighting for Zig code? Then we could make |
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 |
This should be fixed by 2e5a2a5. I used folke/tokyonight.nvim and set BeforeAfter |
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
The text was updated successfully, but these errors were encountered: