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.23k stars 53 forks source link

Sometimes <a-n> does not work but <a-p> does. #204

Closed CapSel closed 4 months ago

CapSel commented 4 months ago

Describe the bug I have a big C++ code that I can't share. There is a if, then inside range loop declaring a variable, and this variable is used 2 times inside a loop. I can use <a-p> to switch between all 3 references (declaration, 2 uses) of variable but <a-n> works only when cursor is on uses.

I verified that it's not problem with shortcuts - giving command :lua require('illuminate').goto_prev_reference() works like <a-p>, with :lua require('illuminate').goto_next_reference() works like <a-n>.

To Reproduce open big C++ code base... and function with range loop... I can't really narrow it down further. I'm forbidden from sharing the code or what it does.

Note Omitting a minimal init.vim/init.lua/.vimrc will likely result in the issue being closed without explanation.

Output from :IlluminateDebug will see what :IlluminateDebug does tomorrow. I could not find info about debugging before reporting this bug.

Expected behavior behavior of <a-n> should be reverse of <a-p>

CapSel commented 4 months ago

:IlluminateDebug:

buf_should_illuminate 1 true
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 = { "lsp", "treesitter", "regex" },
   providers_regex_syntax_allowlist = {},
   providers_regex_syntax_denylist = {},
   under_cursor = true
} 
started true
provider table: 0x7f36079ee650 lsp
`termguicolors` true
RRethy commented 4 months ago

Note Omitting a minimal init.vim/init.lua/.vimrc will likely result in the issue being closed without explanation.

I am unable to reproduce. A minimal init.lua and a minimal C++ file is required. There is likely an interaction going on with another plugin since the goto code has no knowledge about declaration/use for references https://github.com/RRethy/vim-illuminate/blob/5eeb7951fc630682c322e88a9bbdae5c224ff0aa/lua/illuminate/goto.lua#L1-L63.

CapSel commented 3 weeks ago

@RRethy I created repo with code that represents the problem. Could you take a look at it? https://github.com/CapSel/vim-iluminate-bug