Closed anntzer closed 7 years ago
all I can think of tonight, untested:
let g:Poppy = -1
nmap <leader>hp :let g:Poppy = -g:Poppy \| exe 'au! CursorMoved *' . (g:Poppy>0 ? ' call PoppyInit()' : '')<cr>
you may need to make a augroup or function
sorry, now above is working. you should use a augroup with that mapping to not remove other plugins autocmds
The example you give is not working, because the |
need to be replaced by <bar>
. But your suggestion led me to
augroup Poppy | autocmd! CursorMoved | augroup END
nmap <silent> <leader>hp :let g:poppy = -g:poppy <bar> exe 'au! Poppy CursorMoved *' . (g:poppy > 0 ? ' call PoppyInit()' : '') <cr>
which is nearly working.
A minor remaining issue is that turning off poppy-mode in such a way does not clear the currently highlighted parentheses.
just add a call to clearmatches()
or filter the w:poppies
variable, calling matchdelete()
augroup Poppy | autocmd! CursorMoved | augroup END
nmap <silent> <leader>hp :call clearmatches() \| let g:poppy = -g:poppy \| exe 'au! Poppy CursorMoved *' . (g:poppy > 0 ? ' call PoppyInit()' : '') <cr>
Thanks for your quick reply to my question on reddit :-)
I can add a mapping to switch poppy on with e.g.
but it would be even better if I could have the same mapping toogle it on and off. Thoughts?