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

Error occurs when LspStop and move the cursor #101

Closed yutkat closed 2 years ago

yutkat commented 2 years ago

Describe the bug I want to turn off LSP when Neovim is running slow, but when I do LspStop I get an error from vim-illuminate.

Error message:

Error detected while processing CursorMoved Autocommands for "<buffer=1>":
method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer

I think the problem is that there is no check for LSP status in this part of the condition. https://github.com/RRethy/vim-illuminate/blob/3b9b6481a659bdc37a55f488c92839e3804ca098/lua/illuminate.lua#L87

To Reproduce

  1. Using nvim-lsp in Neovim
  2. setup require("illuminate").on_attach(client)
  3. :LspStop
  4. Move the cursor
  5. Error displayed
    Error detected while processing CursorMoved Autocommands for "<buffer=1>":
    method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer

Expected behavior No errors are displayed.

Additional context If you execute this command, no error will occur. :autocmd! vim_illuminate_lsp1