vim9script import autoload "kg8m/events.vim" export def Define(): void nnoremap / ClearHlsearch() nnoremap / EnterSearch() cnoremap ExitCmdline() enddef def ClearHlsearch(): string const clear = ":nohlsearch\" const notify = "\events.NotifyClearSearchHighlight()\" const teardown = ":echo ''\" return clear .. notify .. teardown enddef def EnterSearch(): string const enable_highlight = ":set hlsearch\" const enter_with_very_magic = "/\\v" return enable_highlight .. enter_with_very_magic enddef def ExitCmdline(): string const original = "\" if getcmdtype() ==# "/" return original .. ClearHlsearch() else return original endif enddef