Error when using lsp

E5108: Error executing lua ...s\neovim\current\share\nvim\runtime/lua/vim/lsp/util.lua:110: Invalid encoding: "utf8"
stack traceback:
        [C]: in function 'error'
        ...s\neovim\current\share\nvim\runtime/lua/vim/lsp/util.lua:110: in function '_str_utfindex_enc'
        ...s\neovim\current\share\nvim\runtime/lua/vim/lsp/util.lua:411: in function 'apply_text_edits'
        ...im-data\site\pack\packer\start\nvim-cmp/lua/cmp/core.lua:402: in function <...im-data\site\pack\packer\start\nvim-cmp/lua/cmp/core.lua:375>
        ...te\pack\packer\start\nvim-cmp/lua/cmp/utils/feedkeys.lua:51: in function <...te\pack\packer\start\nvim-cmp/lua/cmp/utils/feedkeys.lua:49>

is this normal? i m using windows btw.

i type print then tab for nvim-cmp. the error shows. i dont think i have did anything wrong.

my neovim config

As far as I know, full UTF-8 support first exists since Windows 11, but since I don’t use Windows myself, I can’t confirm that.

This is a plugin error, not a neovim error. “utf-8” here refers to the offsetEncoding. Neovim follows clangd’s offsetEncoding Protocol extensions which allows servers to send utf-8 offsetEncodings (raw byte ranges), utf-16 encodings (2 byte code points), and utf-32 encodings (the direct 4 byte encodings of code units). These encodings are only used when representing Position params.

Recently, I realized many plugins were using lsp internal utility functions which relied on lazily resolving the offsetEncoding, and would indiscriminately fallback to utf-16 which is the only “official” encoding in the protocol. I changed this so all functions which deal with offsetEncoding require it to be explicitly passed. This helped me catch several bugs internally, and also made apparent some issues in plugins that were not handling multibyte edits correct.

thanks it is solved by @hrsth. btw how can i remove the ^M after formatting using null? it is kknda annoying

it’s already fixed on master. Please search before asking. Lsp.buf.formatting() adds ^M to lines it touches - #5 by mjlbach

i m on master. but it is still there…

Ok, well, try purging neovim and reinstalling. I tested on Windows and the issue is resolved.

uninstalling it and reinstallng it? i tried that but it didnt work

version 0.6.1 is the current version m on

the fix is in master, not 0.6.1…