Open ZacharyRizer opened 3 years ago
I just took a look at the code of vim-slash and I came up with
augroup Loupe
autocmd!
" autocmd CursorMoved,CursorMovedI * set nohlsearch | autocmd! Loupe
autocmd CursorMoved,CursorMovedI * :execute "normal \<Plug>(LoupeClearHighlight)"
augroup END
But this doesn't quite work. Or rather: it works a bit too good: since n
moves the cursor, it removes the highlighting everywhere while searching.
A comment in is.vim specifically says
Make sure move cursor by search related action after calling this function because the first move event just set nested autocmd which does :nohlsearch
so they do this
Maybe someone else has an idea on how to improve this
I'm trying this out and have a similar feeling. I coded something like this
function _G.coh()
if vim.o.hlsearch then
vim.fn['loupe#hlmatch']()
else
vim.fn['loupe#private#clear_highlight']()
end
end
vim.cmd('autocmd OptionSet hlsearch call v:lua.coh()')
@miallo this is neovim's lua, it's mostly the same in viml.
Feels hacky though, calling loupe#private...
, Is there any chance to get this into the plugin instead?
@davidsu Can't you "type" <Plug>(LoupeClearHighlight)
? This will call that function for you without that hack.
At some point I wanted to take a look at lua, but so far my neovim-config is all vimscript...
Was curious if implementing something similar to vim-slash and is.vim in regards to automatically calling :nohl after you move your cursor after n or N. I appreciate the mapping to be able to call :nohl, but I get tired of having to do that all the time.