summaryrefslogtreecommitdiffstats
path: root/ftplugin/racket.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ftplugin/racket.vim')
-rw-r--r--ftplugin/racket.vim23
1 files changed, 21 insertions, 2 deletions
diff --git a/ftplugin/racket.vim b/ftplugin/racket.vim
index 89990061..1a3ba189 100644
--- a/ftplugin/racket.vim
+++ b/ftplugin/racket.vim
@@ -4,6 +4,11 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'racket') == -1
" Maintainer: Will Langstroth <will@langstroth.com>
" URL: http://github.com/wlangstroth/vim-racket
+if exists("b:did_ftplugin")
+ finish
+endif
+let b:did_ftplugin = 1
+
setl iskeyword+=#,%,^
setl lispwords+=module,module*,module+,parameterize,let-values,let*-values,letrec-values,local
setl lispwords+=define-values,opt-lambda,case-lambda,syntax-rules,with-syntax,syntax-case,syntax-parse
@@ -37,7 +42,10 @@ setl makeprg=raco\ make\ --\ %
" but then vim says:
" "press ENTER or type a command to continue"
" We avoid the annoyance of having to hit enter by remapping K directly.
-nnoremap <buffer> K :silent !raco docs <cword><cr>:redraw!<cr>
+nnoremap <buffer> <Plug>RacketDoc :silent !raco docs <cword><cr>:redraw!<cr>
+if maparg("K", "n") == ""
+ nmap <buffer> K <Plug>RacketDoc
+endif
" For the visual mode K mapping, it's slightly more convoluted to get the
" selected text:
@@ -53,9 +61,20 @@ function! s:Racket_visual_doc()
endtry
endfunction
-vnoremap <buffer> K :call <SID>Racket_visual_doc()<cr>
+vnoremap <buffer> <Plug>RacketDoc :call <SID>Racket_visual_doc()<cr>
+if maparg("K", "v") == ""
+ vmap <buffer> K <Plug>RacketDoc
+endif
"setl commentstring=;;%s
setl commentstring=#\|\ %s\ \|#
+" Undo our settings when the filetype changes away from Racket
+" (this should be amended if settings/mappings are added above!)
+let b:undo_ftplugin =
+ \ "setl iskeyword< lispwords< lisp< comments< formatoptions<"
+ \. "| setl makeprg< commentstring<"
+ \. "| nunmap <buffer> K"
+ \. "| vunmap <buffer> K"
+
endif