-
Notifications
You must be signed in to change notification settings - Fork 797
warning: multiple different client offset_encodings detected for buffer, this is not supported yet #428
Comments
So we can set diff --git a/lua/null-ls/client.lua b/lua/null-ls/client.lua
index a49aebc..24ada84 100644
--- a/lua/null-ls/client.lua
+++ b/lua/null-ls/client.lua
@@ -69,6 +69,7 @@ M.start_client = function(fname)
)
end
end),
+ offset_encoding = "utf-8",
}
log:trace("starting null-ls client") This fixes the warning when using If I understand correctly, this is a legitimate warning that would also be triggered when using 2 actual LSP servers with different offset encodings, right? I'm not sure if there's anything we can do about this until multiple offset encodings are supported (apart from maybe putting in an upstream PR to reduce the frequency of the warning, since it's pretty aggressive). |
FYI we didn't use to support mixed offsetEncodings, it used to send the wrong ranges (always utf-16). We changed it to send the correct ranges but with the limitation that it only supports a single offset encoding per buffer. All clients attached to a given buffer must have the same client.offset_encoding (capability only indicates to the language server what our client supports). I assume the issue for null-ls is that there cannot be "groups" of null-ls clients with different offset encodings. |
I was doing some testing and here are the results. Changing the settings in https://github.com/neovim/nvim-lspconfig/blob/c37bf4a2e87df0da5895402b01b427442e0633ff/lua/lspconfig/server_configurations/clangd.lua -- results in 'utf-8'
offsetEncoding = { 'utf-8', 'utf-16' },
-- results in 'utf-16', probably wrong syntax
offsetEncoding = 'utf-8',
-- results in 'utf-8' but null-ls is 'utf-16' anyway
offsetEncoding = { 'utf-8' },
Edit: I was probably modifying the wrong value in null-ls 😅 |
Thanks for the info, this makes sense. The warning should only pop up in the presence of a different client, since all null-ls clients (and there should only be one unless something went wrong) will always have the same offset encoding. @kylo252 I think this diff makes diff --git a/lua/null-ls/client.lua b/lua/null-ls/client.lua
index a49aebc..97c0a3d 100644
--- a/lua/null-ls/client.lua
+++ b/lua/null-ls/client.lua
@@ -69,6 +69,7 @@ M.start_client = function(fname)
)
end
end),
+ client_encoding = "utf-8",
}
log:trace("starting null-ls client")
diff --git a/lua/null-ls/diff.lua b/lua/null-ls/diff.lua
index 20e3dab..311524f 100644
--- a/lua/null-ls/diff.lua
+++ b/lua/null-ls/diff.lua
@@ -140,8 +140,8 @@ function M.compute_diff(old_lines, new_lines, line_ending)
adj_end_char = #old_lines[#old_lines + end_line + 1] + end_char + 1
end
- _, start_char = vim.str_utfindex(old_lines[start_line], start_char - 1)
- _, end_char = vim.str_utfindex(old_lines[#old_lines + end_line + 1], adj_end_char)
+ start_char = start_char - 1
+ end_char = adj_end_char
local result = {
range = { The issue is then that we get the same warning with |
For visibility from a discussion here, an interim "solution" (at least to get rid of the warning that happens on every key press in insert mode) is to do what is mentioned there: local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.offsetEncoding = { "utf-16" }
require("lspconfig").clangd.setup({ capabilities = capabilities }) and all seems to still work as normal. I run |
Just a heads-up, |
Thanks for the workaround! I'll pin the issue for now. |
I haven't even mentioned c filetype in null-ls config, still it attaches to the buffer for some reason. |
@Chaitanyabsprip From your dotfiles, it looks like you are using the Ideally, null-ls wouldn't receive |
👋 there, I am also running into this Is there an easy way to debug this? edit: nvm this works if I switch to clang instead of ccls |
Just some relevant information |
Now, null_ls is buggy when using C, so turn it off. jose-elias-alvarez/null-ls.nvim#428 Add terminal settings.
Currently causes offset encoding error: jose-elias-alvarez/null-ls.nvim#428
Even though I used Neovim Version: null-ls config:
|
Is it possible to make |
It is configurable for null-ls in the same way it's configurable for any other client. I'm going to update the OP with a workaround and close this issue, since it is not specific to null-ls (you can easily replicate it by attaching 2 LSP clients with different offset encoding to a single buffer). |
I found a simple way to config
Given null-ls has some shortcuts for its client/server interaction, it's not required to do the offsetEncoding negotiation, for which the details, see |
MAINTAINER EDIT: this is not a null-ls issue, and you will see the same warning when two clients with different offset encodings are attached to the same buffer. As the error message states, this is not supported yet, and the fundamental fix must be implemented upstream.
This is a legitimate warning, but if you don't care and just want to suppress it, you can filter it out by overriding
vim.notify
:Any further issues about this topic will be closed.
FAQ
Issues
Neovim Version
NVIM v0.7.0-dev+717-gf37c5f180
null-ls config
Steps to reproduce
This validation is introduced in neovim/neovim#16382
You need to have
clangd
which sets an offset encoding by default, running and then any source that attaches to the same buffer.Expected behavior
NA
Actual behavior
NA
Debug log
NA
Help
Yes, but I don't know how to start. I would need guidance
Implementation help
Not really sure how we can get around this. I thought It's probably sufficient to set the same encoding value as
clangd
but that didn't seem to fix it.I also have no idea if there are any downsides to that.
The text was updated successfully, but these errors were encountered: