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

Only warn about offset encoding differences once per buffer #16694

Closed
wants to merge 1 commit into from

Conversation

levouh
Copy link
Sponsor Contributor

@levouh levouh commented Dec 17, 2021

Not sure if this is the right way to go about doing this, but after the commit here every time I type in insert-mode with clangd (reports { "utf-8", "utf-16" }) and null-ls (reports "utf-16") attached attached to a buffer, I get this warning.

Perhaps there is something deeper going on where I should be forcing a client to use a particular encoding? If that is the case, feel free to close this.

Otherwise, it seems sufficient to only warn about this once per buffer; it can be assaulting to have it every time this function is called (especially if using something like nvim-notify).

@github-actions github-actions bot added lsp lua stdlib labels Dec 17, 2021
@levouh
Copy link
Sponsor Contributor Author

levouh commented Dec 17, 2021

Perhaps it would be better to check the type of each of the reported client.config.capabilities.offsetEncoding values and check if they overlap (e.g. "utf-8" in { "utf-8", "utf-16" }).

It is also possible that I have something wrong in my configuration with the passed capabilities when initializing each server, so checking that first.

Moving to a draft for now as this is not in a truly ready state at all; just a potentially wrong solution to a problem that might not even exist.

@levouh levouh marked this pull request as draft December 17, 2021 18:09
@mjlbach
Copy link
Contributor

mjlbach commented Dec 17, 2021

I'd rather fix the offset encoding issues (really, the buf_request api issue) in the 0.7 cycle than add workarounds for a plugin in core.

@ranjithshegde
Copy link

Perhaps there is something deeper going on where I should be forcing a client to use a particular encoding? If that is the case, feel free to close this.

Absolutely. I had the same problem with clangd (when attached with other lsps).
You could simply do

    local capabilities = vim.lsp.protocol.make_client_capabilities()
    capabilities.offsetEncoding = { "utf-16" }
    require('lspconfig').clangd.setup({capabilities = capabilities})

I go with utf-16 as it is the default for most...

@mjlbach
Copy link
Contributor

mjlbach commented Dec 17, 2021

Yes forcing clangd to run in utf-16 is the best solution (for now).

@levouh
Copy link
Sponsor Contributor Author

levouh commented Dec 17, 2021

Makes sense. Is this a bad idea to belligerently set for everything? I imagine it requires coordination with what the server supports.

@mjlbach
Copy link
Contributor

mjlbach commented Dec 18, 2021

Is this a bad idea to belligerently set for everything?

Yes, also running as utf-8 avoids some costly utf handling conversions. Nothing you will notice, that is just the advantage (neovim is utf-8 native)

@kylo252
Copy link
Contributor

kylo252 commented Dec 18, 2021

FWIW, you could also use this flag --offset-encoding=utf-16 with clangd.

@chrisfair
Copy link

Has this changed any lately I found myself having to do this in Lunarvim and it actually works poorly with another plugin I am trying to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants