Files
dotfiles/dot_config/nvim/lua/plugins/illuminate.lua
T
2026-10-05 12:59:47 -04:00

33 lines
1.2 KiB
Lua

vim.pack.add({
{ src = "https://github.com/RRethy/vim-illuminate" },
})
require("illuminate").configure({
-- Providers in order of preference; treesitter provider needs the old
-- nvim-treesitter API (nvim-treesitter.locals), so leave it out
providers = { "lsp", "regex" },
under_cursor = false,
delay = 100,
})
-- The engine picks the first *ready* provider and never falls back per query,
-- so with an LSP attached the regex provider never runs. LSP documentHighlight
-- is semantic-only: words inside strings and non-symbol identifiers (e.g. the
-- `world` in "Hello, world!" or a package name) get an empty result. Patch the
-- LSP provider to fall back to regex matching when the server returns nothing.
local lsp = require("illuminate.providers.lsp")
local regex = require("illuminate.providers.regex")
local lsp_get_references = lsp.get_references
lsp.get_references = function(bufnr, cursor)
local refs = lsp_get_references(bufnr)
if refs and #refs == 0 then
return regex.get_references(bufnr, cursor)
end
return refs
end
-- Default plugin keymaps (set unless already taken):
-- <A-n> next reference
-- <A-p> previous reference
-- <A-i> select reference (text object, operator/visual pending)