-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
[BUG] Heavy flow of errors with NixD #2390
Comments
@inclyc do you think this issue is on our side ? |
According to nixd's log I think it works as expected, can you take a look? @GaetanLepage |
Yes, as I said lsp works fine |
Sounds similar to report in #2290 . It doesn't seem to affect everyone so I'm not sure of the root cause, yet. |
UPD someone figured out that issues appears only if nerdfont's glyths are used in file |
Interesting, I haven't had the issue with other unicode characters... I do sometimes include emoji in my nix comments. It is worth noting that nix strings themselves don't have UTF-8 support, so if nix evaluates a unicode string you can run into issues. IDK if nixd actually evaluates any strings using nix, but maybe they have similar bugs on their end? |
for me this happens (recently? not sure I had this before) when editing files which have unicode in them. In a nix config I have this line:
and now nixvim with nixd throws errors when opening the file which make editing pretty hard. |
I can reproduce this issue with neovim |
So this is neovim problem? Gotta open issue in their repo. |
Yes, I've bisected the issue to neovim/neovim@b55435f bisect log
|
There is one already open in neovim/neovim#30675 The workaround in the issue above seems to be working as well. Just add NeoVimlocal nvim_lsp = require 'lspconfig'
nvim_lsp.nixd.setup {
offset_encoding = 'utf-8',
settings = {
...
},
} NixVimplugins.lsp.servers.nixd = {
enable = true;
extraOptions = {
offset_encoding = "utf-8";
};
}; |
Thanks for the investigation @eljamm ! |
So I set offset_encoding = "utf-8" And I have no errors but syntax highlights changed a lot |
I didn't notice at first as both colors are similar in my colorscheme. Interestingly, this also doesn't happen right after opening the file. To trigger it, I need to insert a newline under a line which has a glyph in it. Editing all the other lines is fine.
If it weren't for the broken syntax highlighting, I'd say we go for it, but perhaps it would be better to wait until we can patch this. I don't know how many people are affected, but they'll probably find this issue and the workaround and choose if it's worth to use it or just roll back Neovim. |
Looking at the lua above, it seems this would need to be set in
I can see differences between left & right, but I can't see any issues in your screenshot. At first glance it just looks like the right hand side is using LSP-based syntax highlighting while the left hand side is not. Your left hand side also doesn't seem to be using treesitter highlighting,1 which may explain why the difference is so stark? Footnotes |
I don't recommend setting it globally, it can cause troubles in other servers. AFAIK content encoding is negotiated between the server and the client, but only since lsp spec 3.17 Before it was always utf-16.. And spec states that support for utf-16 is mandatory. By forcing it to utf-8 on neovim side encoding can be mismatched between the client and the server in some cases. This issue was a regression that was backported in 0.10. It should be fixed now in 0.10 branch, but I don't know when 0.10.3 will be released. Maybe a temporary patch can be included to nixpkgs: neovim/neovim@84bbbd9. Since it's the bug in Nvim, not in Nixvim, I don't think here is the place for workarounds line that, that are valuable only for one specific version of Neovim (0.10.2). |
Byte index encoding bounds were previously only checked against the UTF-8 length, whereas the default is UTF-16, which caused undefined behaviour. neovim/neovim#30747 nix-community/nixvim#2390
Byte index encoding bounds were previously only checked against the UTF-8 length, whereas the default is UTF-16, which caused undefined behaviour. neovim/neovim#30747 nix-community/nixvim#2390
Fix byte index encoding bounds, which were previously only checked against the UTF-8 length, whereas the default is UTF-16, which caused undefined behaviour. See: - neovim/neovim#30747 - nix-community/nixvim#2390
Have you tried using nightly neovim to see if it resolves your issues? I was able to use nixd with it (I had other plugins I needed to work so I rolled back to stable) |
For anyone who missed it, there's also an overlay suggested here that you can use to apply the fix to neovim 0.10, while we wait for 0.10.3 (final: prev: {
neovim-unwrapped = prev.neovim-unwrapped.overrideAttrs (old: {
patches = old.patches ++ [
# Fix byte index encoding bounds.
# - https://github.com/neovim/neovim/pull/30747
# - https://github.com/nix-community/nixvim/issues/2390
(final.fetchpatch {
name = "fix-lsp-str_byteindex_enc-bounds-checking-30747.patch";
url = "https://patch-diff.githubusercontent.com/raw/neovim/neovim/pull/30747.patch";
hash = "sha256-2oNHUQozXKrHvKxt7R07T9YRIIx8W3gt8cVHLm2gYhg=";
})
];
});
}) |
lspconfig
unstable
unstable
Description
error i get every time editing configuration.nix
Logs
Minimal, Reproducible Example (MRE)
also nixd installed with environment.systemPackages. except flow of errors, lsp works fine
The text was updated successfully, but these errors were encountered: