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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
" slimv-lisp.vim:
" Lisp filetype plugin for Slimv
" Version: 0.9.13
" Last Change: 04 May 2014
" Maintainer: Tamas Kovacs <kovisoft at gmail dot com>
" License: This file is placed in the public domain.
" No warranty, express or implied.
" *** *** Use At-Your-Own-Risk! *** ***
"
" =====================================================================
"
" Load Once:
if exists("b:did_ftplugin") || exists("g:slimv_disable_lisp")
finish
endif
" Handle cases when lisp dialects explicitly use the lisp filetype plugins
if &ft == "clojure" && exists("g:slimv_disable_clojure")
finish
endif
if &ft == "scheme" && exists("g:slimv_disable_scheme")
finish
endif
" ---------- Begin part loaded once ----------
if !exists( 'g:slimv_lisp_loaded' )
let g:slimv_lisp_loaded = 1
" Descriptor array for various lisp implementations
" The structure of an array element is:
" [ executable, implementation, platform, search path]
" where:
" executable - may contain wildcards but only if a search path is present
" platform - 'w' (Windows) or 'l' (Linux = non-Windows), '' for all
" search path - commma separated list, may contain wildcard characters
let s:lisp_desc = [
\ [ 'sbcl', 'sbcl', '', '' ],
\ [ 'clisp', 'clisp', '', '' ],
\ [ 'gcl', 'clisp', '', '' ],
\ [ 'cmucl', 'cmu', '', '' ],
\ [ 'ecl', 'ecl', '', '' ],
\ [ 'acl', 'allegro', '', '' ],
\ [ 'mlisp', 'allegro', '', '' ],
\ [ 'mlisp8', 'allegro', '', '' ],
\ [ 'alisp', 'allegro', '', '' ],
\ [ 'alisp8', 'allegro', '', '' ],
\ [ 'lwl', 'lispworks', '', '' ],
\ [ 'ccl', 'clozure', '', '' ],
\ [ 'wx86cl64', 'clozure', 'w64', '' ],
\ [ 'wx86cl', 'clozure', 'w', '' ],
\ [ 'lx86cl', 'clozure', 'l', '' ],
\ [ '*lisp.exe', 'clisp', 'w',
\ 'c:/*lisp*,c:/*lisp*/*,c:/*lisp*/bin/*,c:/Program Files/*lisp*,c:/Program Files/*lisp*/*,c:/Program Files/*lisp*/bin/*' ],
\ [ 'gcl.exe', 'clisp', 'w', 'c:/gcl*,c:/Program Files/gcl*' ],
\ [ 'cmucl.exe', 'cmu', 'w', 'c:/cmucl*,c:/Program Files/cmucl*' ],
\ [ '*lisp*.exe', 'allegro', 'w', 'c:/acl*,c:/Program Files/acl*,c:/Program Files/*lisp*/bin/acl*' ],
\ [ 'ecl.exe', 'ecl', 'w', 'c:/ecl*,c:/Program Files/ecl*' ],
\ [ 'wx86cl64.exe', 'clozure', 'w64', 'c:/ccl*,c:/Program Files/ccl*,c:/Program Files/*lisp*/bin/ccl*' ],
\ [ 'wx86cl.exe', 'clozure', 'w', 'c:/ccl*,c:/Program Files/ccl*,c:/Program Files/*lisp*/bin/ccl*' ],
\ [ 'sbcl.exe', 'sbcl', 'w', 'c:/sbcl*,c:/Program Files/sbcl*,c:/Program Files/*lisp*/bin/sbcl*'] ]
" Try to autodetect Lisp executable
" Returns list [Lisp executable, Lisp implementation]
function! SlimvAutodetect( preferred )
for lisp in s:lisp_desc
if lisp[2] =~ 'w' && !g:slimv_windows
" Valid only on Windows
elseif lisp[2] == 'w64' && $ProgramW6432 == ''
" Valid only on 64 bit Windows
elseif lisp[2] == 'l' && g:slimv_windows
" Valid only on Linux
elseif a:preferred != '' && a:preferred != lisp[1]
" Not the preferred implementation
elseif lisp[3] != ''
" A search path is given
let lisps = split( globpath( lisp[3], lisp[0] ), '\n' )
if len( lisps ) > 0
return [lisps[0], lisp[1]]
endif
else
" Single executable is given without path
if executable( lisp[0] )
return lisp[0:1]
endif
endif
endfor
return ['', '']
endfunction
" Try to find out the Lisp implementation
function! SlimvImplementation()
if exists( 'g:slimv_impl' ) && g:slimv_impl != ''
" Return Lisp implementation if defined
return tolower( g:slimv_impl )
endif
let lisp = tolower( g:slimv_lisp )
if match( lisp, 'sbcl' ) >= 0
return 'sbcl'
endif
if match( lisp, 'cmu' ) >= 0
return 'cmu'
endif
if match( lisp, 'acl' ) >= 0 || match( lisp, 'alisp' ) >= 0 || match( lisp, 'mlisp' ) >= 0
return 'allegro'
endif
if match( lisp, 'ecl' ) >= 0
return 'ecl'
endif
if match( lisp, 'x86cl' ) >= 0
return 'clozure'
endif
if match( lisp, 'lwl' ) >= 0
return 'lispworks'
endif
return 'clisp'
endfunction
" Try to autodetect SWANK and build the command to load the SWANK server
function! SlimvSwankLoader()
" First check if SWANK is bundled with Slimv
let swanks = split( globpath( &runtimepath, 'slime/start-swank.lisp'), '\n' )
if len( swanks ) == 0
" Try to find SWANK in the standard SLIME installation locations
if g:slimv_windows || g:slimv_cygwin
let swanks = split( globpath( 'c:/slime/,c:/*lisp*/slime/,c:/*lisp*/site/lisp/slime/,c:/Program Files/*lisp*/site/lisp/slime/', 'start-swank.lisp' ), '\n' )
else
let swanks = split( globpath( '/usr/share/common-lisp/source/slime/', 'start-swank.lisp' ), '\n' )
endif
endif
if len( swanks ) == 0
return ''
endif
" Build proper SWANK loader command for the Lisp implementation used
if g:slimv_impl == 'sbcl'
return '"' . g:slimv_lisp . '" --load "' . swanks[0] . '"'
elseif g:slimv_impl == 'clisp'
return '"' . g:slimv_lisp . '" -i "' . swanks[0] . '"'
elseif g:slimv_impl == 'allegro'
return '"' . g:slimv_lisp . '" -L "' . swanks[0] . '"'
elseif g:slimv_impl == 'cmu'
return '"' . g:slimv_lisp . '" -load "' . swanks[0] . '"'
else
return '"' . g:slimv_lisp . '" -l "' . swanks[0] . '"'
endif
endfunction
" Filetype specific initialization for the REPL buffer
function! SlimvInitRepl()
set filetype=lisp
endfunction
" Lookup symbol in the list of Lisp Hyperspec symbol databases
function! SlimvHyperspecLookup( word, exact, all )
if !exists( 'g:slimv_clhs_loaded' )
runtime ftplugin/**/slimv-clhs.vim
endif
let symbol = []
if exists( 'g:slimv_clhs_loaded' )
let symbol = SlimvFindSymbol( a:word, a:exact, a:all, g:slimv_clhs_clhs, g:slimv_clhs_root, symbol )
let symbol = SlimvFindSymbol( a:word, a:exact, a:all, g:slimv_clhs_issues, g:slimv_clhs_root, symbol )
let symbol = SlimvFindSymbol( a:word, a:exact, a:all, g:slimv_clhs_chapters, g:slimv_clhs_root, symbol )
let symbol = SlimvFindSymbol( a:word, a:exact, a:all, g:slimv_clhs_control_chars, g:slimv_clhs_root, symbol )
let symbol = SlimvFindSymbol( a:word, a:exact, a:all, g:slimv_clhs_macro_chars, g:slimv_clhs_root, symbol )
let symbol = SlimvFindSymbol( a:word, a:exact, a:all, g:slimv_clhs_loop, g:slimv_clhs_root, symbol )
let symbol = SlimvFindSymbol( a:word, a:exact, a:all, g:slimv_clhs_arguments, g:slimv_clhs_root, symbol )
let symbol = SlimvFindSymbol( a:word, a:exact, a:all, g:slimv_clhs_glossary, g:slimv_clhs_root, symbol )
endif
if exists( 'g:slimv_clhs_user_db' )
" Give a choice for the user to extend the symbol database
if exists( 'g:slimv_clhs_user_root' )
let user_root = g:slimv_clhs_user_root
else
let user_root = ''
endif
let symbol = SlimvFindSymbol( a:word, a:exact, a:all, g:slimv_clhs_user_db, user_root, symbol )
endif
return symbol
endfunction
" Source Slimv general part
runtime ftplugin/**/slimv.vim
endif "!exists( 'g:slimv_lisp_loaded' )
" ---------- End of part loaded once ----------
runtime ftplugin/**/lisp.vim
" Must be called for each lisp buffer
call SlimvInitBuffer()
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
|