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
LSP document highlight handler broken on latest Neovim master #82
Describe the bughandle_document_highlight hasn't been adapted for neovim/neovim#15504, so the LSP highlighting functionality from vim-illuminate doesn't work on the latest Neovim master.
To Reproduce
Build Neovim from the latest master
Enable the LSP integration for any language server, as described in the readme
Open a file and wait for LSP attach
Hover over a variable
Expected behavior
References get highlighted and moving between references with next_referenceworks.
Additional context
For reference, the following diff fixes the issue while maintaining compatibility with the old handler signature (I didn't put in a PR, since this is just one of many ways to solve the issue):
diff --git a/lua/illuminate.lua b/lua/illuminate.lua
index f4a0b20..8ec81fa 100644
--- a/lua/illuminate.lua
+++ b/lua/illuminate.lua
@@ -51,7 +51,26 @@ local function cursor_in_references(bufnr)
return false
end
-local function handle_document_highlight(_, _, result, _, bufnr, _) -- TODO use client_id
+local function make_handler(fn)
+ return function(...)
+ local config_or_client_id = select(4, ...)
+ local is_new = type(config_or_client_id) ~= 'number'
+ if is_new then
+ fn(...)
+ else
+ local err = select(1, ...)
+ local method = select(2, ...)
+ local result = select(3, ...)
+ local client_id = select(4, ...)
+ local bufnr = select(5, ...)
+ local config = select(6, ...)
+ fn(err, result, { method = method, client_id = client_id, bufnr = bufnr }, config)
+ end
+ end
+end
+
+local handle_document_highlight = make_handler(function(_, result, ctx) -- TODO use client_id
+ bufnr = ctx.bufnr
if not bufnr then return end
local btimer = timers[bufnr]
if btimer then
@@ -71,7 +90,7 @@ local function handle_document_highlight(_, _, result, _, bufnr, _) -- TODO use
return before_by_start(a.range, b.range)
end)
references[bufnr] = result
-end
+end)
local function valid(bufnr, range)
return range
Describe the bug
handle_document_highlight
hasn't been adapted for neovim/neovim#15504, so the LSP highlighting functionality from vim-illuminate doesn't work on the latest Neovim master.To Reproduce
Expected behavior References get highlighted and moving between references with
next_reference
works.Additional context For reference, the following diff fixes the issue while maintaining compatibility with the old handler signature (I didn't put in a PR, since this is just one of many ways to solve the issue):