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.12k stars 44 forks source link

First occurrence not highlighted #123

Closed 0rtz closed 1 year ago

0rtz commented 1 year ago

Hi, I have an issue, as the title says. Definition seems not to be highlighted as an LSP reference. Is it intended? image Minimal vimrc to reproduce:

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir . '/autoload/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

call plug#begin(s:plug_dir)
Plug 'neovim/nvim-lspconfig'
Plug 'RRethy/vim-illuminate'
call plug#end()

if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
    echom 'Some modules are missing, running :PlugInstall'
    PlugInstall --sync
endif

lua <<EOF
local lsp_conf = require'lspconfig'
lsp_conf.clangd.setup({})
EOF

hi IlluminatedWordText cterm=underline
hi IlluminatedWordRead ctermbg=Red
hi IlluminatedWordWrite ctermbg=Red
nnoremap <silent> <c-j> <cmd>lua require('illuminate').goto_next_reference()<CR>
nnoremap <silent> <c-k> <cmd>lua require('illuminate').goto_prev_reference()<CR>

Using NVIM: v0.7.2, vim-illuminate: d7180ed

Btw with treesitter provider, every occurrence is highlighted

0rtz commented 1 year ago

Also using bashls variables are not highlighted with IlluminatedWordRead or IlluminatedWordWrite image

RRethy commented 1 year ago

That's controlled by the LSP and is being highlighted with hi IlluminatedWordText cterm=underline, vim-illuminate has no control over that. In terms of the C++ example, it kind of makes sense though since the declaration isn't a read or a write, it's just allocating the space on the stack (depending on ur version).

FWIW I have all the highlight groups the same because I find what the LSP returns for the reference kind to be inconsistent at times. You could also disable lsp by removing it from the provider list.