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

Add autocmds for lua #96

Closed tamago324 closed 2 years ago

tamago324 commented 2 years ago

Thanks for creating and maintaining a great plugin!

Added autocmd as in VimScript.

tamago324 commented 2 years ago

Thanks for the review. Sorry. I didn't explain it well enough.

The intention of this PR was to control the highlighting by g:Illuminate_insert_mode_highlight. Therefore, I was happy to add only InsertEnter and CursorMovedI. However, in VimScript, WinLeave, BufLeave and InsertLeave also execute autocmd, so I added lua as well.

Also, I tried insertLeave without autocmd, and the highlighting was done when I exited Insert Mode, so I don't think insertLeave is necessary either.

If possible, I would like to remove autocmd for WinLeave, BufLeave and InsertLeave, how about that?

RRethy commented 2 years ago

These autocmds open up potential for a lot of race conditions because vim.lsp.buf.document_highlight() is an async function. I'll think about adding back g:Illuminate_insert_mode_highlight but I'm going to close this PR for now. I'm planning on a partial rewrite of this plugin eventually where I can think about adding back that option.

tamago324 commented 2 years ago

Thank you for your explanation.

I understand. I'm really looking forward to the option of no highlighting in insert mode when this plugin is rewritten.

Thank you.