1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
let s:base = expand("<sfile>:h:h")
let Filter = { _, v -> stridx(v, s:base) == -1 && stridx(v, $VIMRUNTIME) == -1 && v !~ "after" }
let files = filter(globpath(&rtp, 'ftplugin/racket.vim', 1, 1), Filter)
if len(files) > 0
exec 'source ' . files[0]
finish
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'racket') == -1
" Language: Racket
" 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
setl lispwords+=define-signature,unit,unit/sig,compund-unit/sig,define-values/invoke-unit/sig
setl lispwords+=define-opt/c,define-syntax-rule
setl lispwords+=struct
" Racket OOP
setl lispwords+=class,define/public,define/private
" kanren
setl lispwords+=fresh,run,run*,project,conde,condu
" loops
setl lispwords+=for,for/list,for/fold,for*,for*/list,for*/fold,for/or,for/and
setl lispwords+=for/hash,for/sum,for/flvector,for*/flvector,for/vector
setl lispwords+=match,match*,match/values,define/match,match-lambda,match-lambda*,match-lambda**
setl lispwords+=match-let,match-let*,match-let-values,match-let*-values
setl lispwords+=match-letrec,match-define,match-define-values
setl lisp
" Enable auto begin new comment line when continuing from an old comment line
setl comments+=:;
setl formatoptions+=r
setl makeprg=raco\ make\ --\ %
" Simply setting keywordprg like this works:
" setl keywordprg=raco\ docs
" 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> <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:
function! s:Racket_visual_doc()
try
let l:old_a = @a
normal! gv"ay
call system("raco docs '". @a . "'")
redraw!
return @a
finally
let @a = l:old_a
endtry
endfunction
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
|