From 26dbeebebf9ff0315b1abd6925a451c080a66d56 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 14 Dec 2019 18:43:42 +0100 Subject: Add guards around the default mappings Don't define the default `g/` and `g?` mappings if there are already Nohai mappings or if those are already defined. Add a `g:nohai_no_maps` variable to disable plugin mappings. --- plugin/nohai.vim | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'plugin') diff --git a/plugin/nohai.vim b/plugin/nohai.vim index 13a4d27..65d56de 100644 --- a/plugin/nohai.vim +++ b/plugin/nohai.vim @@ -8,5 +8,14 @@ let g:loaded_nohai = 1 nnoremap (nohai-search-backward) nohai#Search('?') nnoremap (nohai-search) nohai#Search('/') -nmap g? (nohai-search-backward) -nmap g/ (nohai-search) +if exists('g:nohai_no_maps') && g:nohai_no_maps + finish +endif + +if !hasmapto('(nohai-search-backward)') && !maparg('g?', 'n') + nmap g? (nohai-search-backward) +endif + +if !hasmapto('(nohai-search)') && !maparg('g/', 'n') + nmap g/ (nohai-search) +endif -- cgit v1.2.3