IlluminatePause command doesn't work properly
When hovering over a reference and executing the :IlluminatePause command, existing highlights are not immediately cleared.
To Reproduce
- Open Neovim.
- Press
ito enter insert mode and enter the textabc def abc. - Press escape to return to normal mode.
- Press
0to position the cursor at the start of the line. - Observe both references to
abcare now highlighted. - Execute the command
:IlluminatePause - Observe that the references to
abcflicker but then stay in a highlighted state until the cursor is moved.
Minimal config: (save as init.lua)
-- Start nvim with the command: `nvim -nu init.lua`
-- To cleanup once finished: `rm -rf ./.repro`
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
vim.fn.system {
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath,
}
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
'RRethy/vim-illuminate',
opts = {
providers = {
'regex',
},
},
config = function(_, opts)
require('illuminate').configure(opts)
end,
}
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
Output from :IlluminateDebug
buf_should_illuminate 1 false
config {
case_insensitive_regex = false,
delay = 100,
filetype_overrides = {},
filetypes_allowlist = {},
filetypes_denylist = { "dirbuf", "dirvish", "fugitive" },
min_count_to_highlight = 1,
modes_allowlist = {},
modes_denylist = {},
providers = { "regex" },
providers_regex_syntax_allowlist = {},
providers_regex_syntax_denylist = {},
under_cursor = true
}
started true
provider table: 0x7486e8650c58 regex
`termguicolors` true
Expected behavior
All currently highlighted references should be cleared when :IlluminatePause is issued, without having to move the cursor.
Additional context Issue seen on Neovim 0.10.1 and 0.9.5.
I think this is happening because buf_highlight_references is being called even when buf_should_illuminate(bufnr) is false (in engine.lua). There is a check for this at the start of the refresh_references function but the value that buf_should_illuminate evaluates to must be different when the callback for the internal timer is executed.
This happens because the command is executed from the command line, I intended this for use in a mapping. I added some additional checks.