From 9eeb2ec25b5d1726b99b2df5c09713a0a136c3d2 Mon Sep 17 00:00:00 2001 From: Marcos Minond Date: Tue, 28 Mar 2023 19:33:00 -0600 Subject: [PATCH] Conditionally unmapping mappings --- ftplugin/racket.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ftplugin/racket.vim b/ftplugin/racket.vim index 551084d..f44cbb4 100644 --- a/ftplugin/racket.vim +++ b/ftplugin/racket.vim @@ -41,7 +41,8 @@ setl makeprg=raco\ make\ --\ % " "press ENTER or type a command to continue" " We avoid the annoyance of having to hit enter by remapping K directly. nnoremap RacketDoc :silent !raco docs :redraw! -if maparg("K", "n") == "" +let b:nmapped_K = maparg("K", "n") == "" +if b:nmapped_K nmap K RacketDoc endif @@ -60,7 +61,8 @@ function! s:Racket_visual_doc() endfunction vnoremap RacketDoc :call Racket_visual_doc() -if maparg("K", "v") == "" +let b:vmapped_K = maparg("K", "v") == "" +if b:vmapped_K vmap K RacketDoc endif @@ -77,6 +79,6 @@ endif let b:undo_ftplugin = \ "setl iskeyword< lispwords< lisp< comments< formatoptions<" \. "| setl makeprg< commentstring<" - \. "| nunmap K" - \. "| vunmap K" + \. (b:nmapped_K ? "| nunmap K" : "") + \. (b:vmapped_K ? "| vunmap K" : "") \. "| unlet! b:browsefilter"