Closed mareksubocz closed 1 month ago
This has been discussed also here: https://www.reddit.com/r/neovim/comments/sld3vr/how_to_autocmd_vimlspbufclear_references_only/
And the solution is to use the plugin: https://github.com/RRethy/vim-illuminate
I tried it and it works as expected, no blinking on cursor move.
Here is the init.lua change that replaces the reference highlight code with the plugin:
diff --git a/init.lua b/init.lua
index 88658ef..d3238f2 100644
--- a/init.lua
+++ b/init.lua
@@ -507,35 +507,6 @@ require('lazy').setup({
-- For example, in C this would take you to the header.
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
- -- The following two autocommands are used to highlight references of the
- -- word under your cursor when your cursor rests there for a little while.
- -- See `:help CursorHold` for information about when this is executed
- --
- -- When you move your cursor, the highlights will be cleared (the second autocommand).
- local client = vim.lsp.get_client_by_id(event.data.client_id)
- if client and client.server_capabilities.documentHighlightProvider then
- local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
- vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
- buffer = event.buf,
- group = highlight_augroup,
- callback = vim.lsp.buf.document_highlight,
- })
-
- vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
- buffer = event.buf,
- group = highlight_augroup,
- callback = vim.lsp.buf.clear_references,
- })
-
- vim.api.nvim_create_autocmd('LspDetach', {
- group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
- callback = function(event2)
- vim.lsp.buf.clear_references()
- vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
- end,
- })
- end
-
-- The following autocommand is used to enable inlay hints in your
-- code, if the language server you are using supports them
--
@@ -625,6 +596,8 @@ require('lazy').setup({
end,
},
+ { 'RRethy/vim-illuminate' },
+
{ -- Autoformat
'stevearc/conform.nvim',
lazy = false,
Love it, thanks a lot!
@feoh should we integrate the above change in kickstart or leave it as is?
And the solution is to use the plugin: https://github.com/RRethy/vim-illuminate
I tried it and it works as expected, no blinking on cursor move.
But why then does kickstart.nvim use some private settings instead of using a specialized plugin?
@dam9000 I don't have strong feelings on this at all, the current behavior is fine by me, if folks feel strongly that's fine.
@denius I don't know, why not run git blame and ask the actual human who made the change rather than focusing on unhelpful generalities? Sorry I find your comment a bit frustrating. It may be time for me to step away from this repository :)
Describe the bug
Every time the cursor moves, the references are cleared, as indicated here:
That means that when the cursor is moved, but stays within the same word, the highlight quickly turns off and on. Is there a fix to that?
To Reproduce
Desktop
Neovim Version
NVIM v0.9.5 Build type: Release LuaJIT 2.1.1710088188
system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.5/share/nvim"