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.14k stars 47 forks source link

Still highlight when leave the current buffer in lsp mode. #78

Closed LimbicSys closed 3 years ago

LimbicSys commented 3 years ago

图片 The left cpp file was opened first. Then I opened a plain text file in the right window, the words in cpp file are still highlighted. If I do not use this plug in lsp mode, it will not highligh the words when I leave the current buffer.

RRethy commented 3 years ago

That's intended behaviour. When using LSP, highlighting is done with :h nvim_buf_add_highlight() while non-lsp highlighting is done with :h matchadd(), the former adds highlighting to the buffer while the latter adds highlighting to the window. Since the latter adds highlighting to the window, it must be removed when leaving the window or it can become invalid.