RRethy / vim-illuminate

illuminate.vim - (Neo)Vim plugin for automatically highlighting other uses of the word under the cursor using either LSP, Tree-sitter, or regex matching.
2.14k stars 47 forks source link

Pass client offset encoding to buf_highlight_references #93

Closed jose-elias-alvarez closed 2 years ago

jose-elias-alvarez commented 2 years ago

neovim/neovim@bc722c8a74766e14aff3a8e2fc46db72ed864053 makes it so that several LSP-related functions, including vim.lsp.util.buf_highlight_references(), require the client's offset encoding to be explicitly passed. At the moment, this causes any cursor movement to throw the following error:

Error executing vim.schedule lua callback: /Users/jose/.local/share/nvim/runtime/lua/vim/lsp/util.lua:1528: offset_encoding: expected string, got number
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        /Users/jose/.local/share/nvim/runtime/lua/vim/lsp/util.lua:1528: in function 'buf_highlight_references'
        ...site/pack/packer/start/vim-illuminate/lua/illuminate.lua:68: in function ''
        vim.lua: in function ''
        vim.lua: in function <vim.lua:0>

This PR fixes the error by getting the client by its ID and passing its offset encoding to the utility. As far as I can tell, this shouldn't cause any changes in behavior on older Neovim versions.

jose-elias-alvarez commented 2 years ago

Thanks for the quick merge!