Closed wardw closed 1 year ago
I put in some building blocks for this, but I avoided adding more complex logic around toggling it for you. You can achieve what you describe with the following snippet:
vim.keymap.set('n', '<leader>i', function()
require('illuminate').toggle_visibility_buf()
end)
local augroup = 'my-vim-illuminate-autocmds'
vim.api.nvim_create_augroup(augroup, { clear = true })
vim.api.nvim_create_autocmd('BufRead', {
group = augroup,
callback = function()
require('illuminate').invisible_buf()
end,
})
Thanks for this. I replaced the event BufRead
with CursorMoved
so the highlighting is automatically dropped (rather than acting as a toggle) and it works well. I've had a look at the code and may even play around a bit more to see if I can add some of the other related logic, but thank you as you say the building blocks are there so that's great.
Love the plugin, thanks. However, sometimes I find the highlighting a bit of a visual distraction and so make good use of
:IlluminateToggle
and find myself toggling quite a bit.I wondered if you might consider a way to have the highlighting off by default, but invokable as a one-time event with a keybinding. For me, this also neatly solves issues around timing/flicker, since by default the code is visually quiet but then when you do want to discover references you just mash a keybinding and the highlights sparkle into existence on request. Clearing the highlights could be done on the next cursor move, much like nvim-treesitter-refactor.
Note that this is complementary to enabling/disabling, since invoking the highlight would be a one-time event with the plugin otherwise remaining enabled. This way you still get the utility of
<a-n>
/<a-p>
even if the highlighting is off, perhaps also just invoking the highlighting as you jump between references.Alternatively, there is nvim-treesitter-refactor but I like this plugin as it wraps treesitter / lsp / regex all in a neat and tidy way, and the automatic highlighting is still a great feature. So regardless, thanks for the nice work!