folke / flash.nvim

Navigate your code with search labels, enhanced character motions and Treesitter integration
Apache License 2.0
2.47k stars 33 forks source link

feature: clear highlight after jumping to first match with `<CR>` #139

Closed gennaro-tedesco closed 1 year ago

gennaro-tedesco commented 1 year ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

Not a problem, and likely I have misunderstood some configuration options. When in search mode, say with /, flash clears the search highlight when selecting a match via a certain label; however, such isn't the case when jumping to the first match via <CR>. I tried setting jump = {nohlsearch = true} to no avail (both in the general jump configuration and in modes.search.jump)

Describe the solution you'd like

Clear search highlight after jumping to first match via <CR>.

Describe alternatives you've considered

Re-mapping <CR> to explicitly clear the search highlights too.

Additional context

I remember seeing a related discussion either as issue or in the "Discussions" section (??), but I couldn't find it (hence sorry if this has been discussed already).

folke commented 1 year ago

That's to be expected. When hitting <CR> during a regular search, flash is not involved. That's just doing a regular search.

To achieve what you want you could just do vim.cmd.nohlsearch() in an CmdlineLeave autocmd