Skip to content

Commit 3186372

Browse files
committed
License + syntax file from VimClojure hg master
0 parents  commit 3186372

2 files changed

Lines changed: 377 additions & 0 deletions

File tree

LICENSE.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright 2008-2011 (c) Meikel Brandmeyer.
2+
All rights reserved.
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
THE SOFTWARE.

syntax/clojure.vim

Lines changed: 357 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
" Vim syntax file
2+
" Language: Clojure
3+
" Maintainer: Toralf Wittner <toralf.wittner@gmail.com>
4+
" modified by Meikel Brandmeyer <mb@kotka.de>
5+
" URL: http://kotka.de/projects/clojure/vimclojure.html
6+
7+
if version < 600
8+
syntax clear
9+
elseif exists("b:current_syntax")
10+
finish
11+
endif
12+
13+
" Highlight superfluous closing parens, brackets and braces.
14+
syn match clojureError "]\|}\|)"
15+
16+
" Special case for Windows.
17+
try
18+
call vimclojure#InitBuffer()
19+
catch /.*/
20+
" We swallow a failure here. It means most likely that the
21+
" server is not running.
22+
echohl WarningMsg
23+
echomsg v:exception
24+
echohl None
25+
endtry
26+
27+
if g:vimclojure#HighlightBuiltins != 0
28+
let s:builtins_map = {
29+
\ "Constant": "nil",
30+
\ "Boolean": "true false",
31+
\ "Cond": "if if-not if-let when when-not when-let "
32+
\ . "when-first cond condp case",
33+
\ "Exception": "try catch finally throw",
34+
\ "Repeat": "recur map mapcat reduce filter for doseq dorun "
35+
\ . "doall dotimes map-indexed keep keep-indexed",
36+
\ "Special": ". def do fn if let new quote var loop",
37+
\ "Variable": "*warn-on-reflection* this *assert* "
38+
\ . "*agent* *ns* *in* *out* *err* *command-line-args* "
39+
\ . "*print-meta* *print-readably* *print-length* "
40+
\ . "*allow-unresolved-args* *compile-files* "
41+
\ . "*compile-path* *file* *flush-on-newline* "
42+
\ . "*math-context* *unchecked-math* *print-dup* "
43+
\ . "*print-level* *use-context-classloader* "
44+
\ . "*source-path* *clojure-version* *read-eval* "
45+
\ . "*fn-loader* *1 *2 *3 *e",
46+
\ "Define": "def- defn defn- defmacro defmulti defmethod "
47+
\ . "defstruct defonce declare definline definterface "
48+
\ . "defprotocol defrecord deftype",
49+
\ "Macro": "and or -> assert with-out-str with-in-str with-open "
50+
\ . "locking destructure ns dosync binding delay "
51+
\ . "lazy-cons lazy-cat time assert with-precision "
52+
\ . "with-local-vars .. doto memfn proxy amap areduce "
53+
\ . "refer-clojure future lazy-seq letfn "
54+
\ . "with-loading-context bound-fn extend extend-protocol "
55+
\ . "extend-type reify with-bindings ->>",
56+
\ "Func": "= not= not nil? false? true? complement identical? "
57+
\ . "string? symbol? map? seq? vector? keyword? var? "
58+
\ . "special-symbol? apply partial comp constantly "
59+
\ . "identity comparator fn? re-matcher re-find re-matches "
60+
\ . "re-groups re-seq re-pattern str pr prn print "
61+
\ . "println pr-str prn-str print-str println-str newline "
62+
\ . "macroexpand macroexpand-1 monitor-enter monitor-exit "
63+
\ . "eval find-doc file-seq flush hash load load-file "
64+
\ . "read read-line scan slurp subs sync test "
65+
\ . "format printf loaded-libs use require load-reader "
66+
\ . "load-string + - * / +' -' *' /' < <= == >= > dec dec' "
67+
\ . "inc inc' min max "
68+
\ . "neg? pos? quot rem zero? rand rand-int decimal? even? "
69+
\ . "odd? float? integer? number? ratio? rational? "
70+
\ . "bit-and bit-or bit-xor bit-not bit-shift-left "
71+
\ . "bit-shift-right symbol keyword gensym count conj seq "
72+
\ . "first rest ffirst fnext nfirst nnext second every? "
73+
\ . "not-every? some not-any? concat reverse cycle "
74+
\ . "interleave interpose split-at split-with take "
75+
\ . "take-nth take-while drop drop-while repeat replicate "
76+
\ . "iterate range into distinct sort sort-by zipmap "
77+
\ . "line-seq butlast last nth nthnext next "
78+
\ . "repeatedly tree-seq enumeration-seq iterator-seq "
79+
\ . "coll? associative? empty? list? reversible? "
80+
\ . "sequential? sorted? list list* cons peek pop vec "
81+
\ . "vector peek pop rseq subvec array-map hash-map "
82+
\ . "sorted-map sorted-map-by assoc assoc-in dissoc get "
83+
\ . "get-in contains? find select-keys update-in key val "
84+
\ . "keys vals merge merge-with max-key min-key "
85+
\ . "create-struct struct-map struct accessor "
86+
\ . "remove-method meta with-meta in-ns refer create-ns "
87+
\ . "find-ns all-ns remove-ns import ns-name ns-map "
88+
\ . "ns-interns ns-publics ns-imports ns-refers ns-resolve "
89+
\ . "resolve ns-unmap name namespace require use "
90+
\ . "set! find-var var-get var-set ref deref "
91+
\ . "ensure alter ref-set commute agent send send-off "
92+
\ . "agent-errors clear-agent-errors await await-for "
93+
\ . "instance? bean alength aget aset aset-boolean "
94+
\ . "aset-byte aset-char aset-double aset-float "
95+
\ . "aset-int aset-long aset-short make-array "
96+
\ . "to-array to-array-2d into-array int long float "
97+
\ . "double char boolean short byte parse add-classpath "
98+
\ . "cast class get-proxy-class proxy-mappings "
99+
\ . "update-proxy hash-set sorted-set set disj set? "
100+
\ . "aclone add-watch alias alter-var-root "
101+
\ . "ancestors await1 bases bigdec bigint bit-and-not "
102+
\ . "bit-clear bit-flip bit-set bit-test counted?"
103+
\ . "char-escape-string char-name-string class? "
104+
\ . "compare compile construct-proxy delay? "
105+
\ . "derive descendants distinct? double-array "
106+
\ . "doubles drop-last empty float-array floats "
107+
\ . "force gen-class get-validator int-array ints "
108+
\ . "isa? long-array longs make-hierarchy method-sig "
109+
\ . "not-empty ns-aliases ns-unalias num partition "
110+
\ . "parents pmap prefer-method primitives-classnames "
111+
\ . "print-ctor print-dup print-method print-simple "
112+
\ . "proxy-call-with-super "
113+
\ . "proxy-super rationalize read-string remove "
114+
\ . "remove-watch replace resultset-seq rsubseq "
115+
\ . "seque set-validator! shutdown-agents subseq "
116+
\ . "supers "
117+
\ . "unchecked-add unchecked-dec unchecked-divide "
118+
\ . "unchecked-inc unchecked-multiply unchecked-negate "
119+
\ . "unchecked-subtract underive xml-seq trampoline "
120+
\ . "atom compare-and-set! ifn? gen-interface "
121+
\ . "intern init-proxy io! memoize proxy-name swap! "
122+
\ . "release-pending-sends the-ns unquote while "
123+
\ . "unchecked-remainder alter-meta! "
124+
\ . "future-call methods mod pcalls prefers pvalues "
125+
\ . "reset! realized? some-fn "
126+
\ . "reset-meta! type vary-meta unquote-splicing "
127+
\ . "sequence clojure-version counted? "
128+
\ . "chunk-buffer chunk-append chunk chunk-first "
129+
\ . "chunk-rest chunk-next chunk-cons chunked-seq? "
130+
\ . "deliver future? future-done? future-cancel "
131+
\ . "future-cancelled? get-method promise "
132+
\ . "ref-history-count ref-min-history ref-max-history "
133+
\ . "agent-error assoc! boolean-array booleans bound-fn* "
134+
\ . "bound? byte-array bytes char-array char? chars "
135+
\ . "conj! denominator disj! dissoc! error-handler "
136+
\ . "error-mode extenders extends? find-protocol-impl "
137+
\ . "find-protocol-method flatten frequencies "
138+
\ . "get-thread-bindings group-by hash-combine juxt "
139+
\ . "munge namespace-munge numerator object-array "
140+
\ . "partition-all partition-by persistent! pop! "
141+
\ . "pop-thread-bindings push-thread-bindings rand-nth "
142+
\ . "reductions remove-all-methods restart-agent "
143+
\ . "satisfies? set-error-handler! set-error-mode! "
144+
\ . "short-array shorts shuffle sorted-set-by take-last "
145+
\ . "thread-bound? transient vector-of with-bindings* fnil "
146+
\ . "spit biginteger every-pred find-keyword "
147+
\ . "unchecked-add-int unchecked-byte unchecked-char "
148+
\ . "unchecked-dec-int unchecked-divide-int "
149+
\ . "unchecked-double unchecked-float "
150+
\ . "unchecked-inc-int unchecked-int unchecked-long "
151+
\ . "unchecked-multiply-int unchecked-negate-int "
152+
\ . "unchecked-remainder-int unchecked-short "
153+
\ . "unchecked-subtract-int with-redefs with-redefs-fn"
154+
\ }
155+
156+
for category in keys(s:builtins_map)
157+
let words = split(s:builtins_map[category], " ")
158+
let words = map(copy(words), '"clojure.core/" . v:val') + words
159+
let s:builtins_map[category] = words
160+
endfor
161+
162+
call vimclojure#ColorNamespace(s:builtins_map)
163+
endif
164+
165+
if g:vimclojure#DynamicHighlighting != 0 && exists("b:vimclojure_namespace")
166+
try
167+
let s:result = vimclojure#ExecuteNailWithInput("DynamicHighlighting",
168+
\ b:vimclojure_namespace)
169+
if s:result.stderr == ""
170+
call vimclojure#ColorNamespace(s:result.value)
171+
unlet s:result
172+
endif
173+
catch /.*/
174+
" We ignore errors here. If the file is messed up, we at least get
175+
" the basic syntax highlighting.
176+
endtry
177+
endif
178+
179+
syn cluster clojureAtomCluster contains=clojureError,clojureFunc,clojureMacro,clojureCond,clojureDefine,clojureRepeat,clojureException,clojureConstant,clojureVariable,clojureSpecial,clojureKeyword,clojureString,clojureCharacter,clojureNumber,clojureBoolean,clojureQuote,clojureUnquote,clojureDispatch,clojurePattern
180+
syn cluster clojureTopCluster contains=@clojureAtomCluster,clojureComment,clojureSexp,clojureAnonFn,clojureVector,clojureMap,clojureSet
181+
182+
syn keyword clojureTodo contained FIXME XXX TODO FIXME: XXX: TODO:
183+
syn match clojureComment contains=clojureTodo ";.*$"
184+
185+
syn match clojureKeyword "\c:\{1,2}[a-z0-9?!\-_+*.=<>#$]\+\(/[a-z0-9?!\-_+*.=<>#$]\+\)\?"
186+
187+
syn region clojureString start=/L\="/ skip=/\\\\\|\\"/ end=/"/
188+
189+
syn match clojureCharacter "\\."
190+
syn match clojureCharacter "\\[0-7]\{3\}"
191+
syn match clojureCharacter "\\u[0-9]\{4\}"
192+
syn match clojureCharacter "\\space"
193+
syn match clojureCharacter "\\tab"
194+
syn match clojureCharacter "\\newline"
195+
syn match clojureCharacter "\\return"
196+
syn match clojureCharacter "\\backspace"
197+
syn match clojureCharacter "\\formfeed"
198+
199+
let radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
200+
for radix in range(2, 36)
201+
execute 'syn match clojureNumber "\c\<-\?' . radix . 'r['
202+
\ . strpart(radixChars, 0, radix)
203+
\ . ']\+\>"'
204+
endfor
205+
206+
syn match clojureNumber "\<-\=[0-9]\+\(\.[0-9]*\)\=\(M\|\([eE][-+]\?[0-9]\+\)\)\?\>"
207+
syn match clojureNumber "\<-\=[0-9]\+N\?\>"
208+
syn match clojureNumber "\<-\=0x[0-9a-fA-F]\+\>"
209+
syn match clojureNumber "\<-\=[0-9]\+/[0-9]\+\>"
210+
211+
syn match clojureQuote "\('\|`\)"
212+
syn match clojureUnquote "\(\~@\|\~\)"
213+
syn match clojureDispatch "\(#^\|#'\)"
214+
syn match clojureDispatch "\^"
215+
216+
syn match clojureAnonArg contained "%\(\d\|&\)\?"
217+
syn match clojureVarArg contained "&"
218+
219+
syn region clojureSexpLevel0 matchgroup=clojureParen0 start="(" matchgroup=clojureParen0 end=")" contains=@clojureTopCluster,clojureSexpLevel1
220+
syn region clojureSexpLevel1 matchgroup=clojureParen1 start="(" matchgroup=clojureParen1 end=")" contained contains=@clojureTopCluster,clojureSexpLevel2
221+
syn region clojureSexpLevel2 matchgroup=clojureParen2 start="(" matchgroup=clojureParen2 end=")" contained contains=@clojureTopCluster,clojureSexpLevel3
222+
syn region clojureSexpLevel3 matchgroup=clojureParen3 start="(" matchgroup=clojureParen3 end=")" contained contains=@clojureTopCluster,clojureSexpLevel4
223+
syn region clojureSexpLevel4 matchgroup=clojureParen4 start="(" matchgroup=clojureParen4 end=")" contained contains=@clojureTopCluster,clojureSexpLevel5
224+
syn region clojureSexpLevel5 matchgroup=clojureParen5 start="(" matchgroup=clojureParen5 end=")" contained contains=@clojureTopCluster,clojureSexpLevel6
225+
syn region clojureSexpLevel6 matchgroup=clojureParen6 start="(" matchgroup=clojureParen6 end=")" contained contains=@clojureTopCluster,clojureSexpLevel7
226+
syn region clojureSexpLevel7 matchgroup=clojureParen7 start="(" matchgroup=clojureParen7 end=")" contained contains=@clojureTopCluster,clojureSexpLevel8
227+
syn region clojureSexpLevel8 matchgroup=clojureParen8 start="(" matchgroup=clojureParen8 end=")" contained contains=@clojureTopCluster,clojureSexpLevel9
228+
syn region clojureSexpLevel9 matchgroup=clojureParen9 start="(" matchgroup=clojureParen9 end=")" contained contains=@clojureTopCluster,clojureSexpLevel0
229+
230+
syn region clojureAnonFn matchgroup=clojureParen0 start="#(" matchgroup=clojureParen0 end=")" contains=@clojureTopCluster,clojureAnonArg,clojureSexpLevel0
231+
syn region clojureVector matchgroup=clojureParen0 start="\[" matchgroup=clojureParen0 end="\]" contains=@clojureTopCluster,clojureVarArg,clojureSexpLevel0
232+
syn region clojureMap matchgroup=clojureParen0 start="{" matchgroup=clojureParen0 end="}" contains=@clojureTopCluster,clojureSexpLevel0
233+
syn region clojureSet matchgroup=clojureParen0 start="#{" matchgroup=clojureParen0 end="}" contains=@clojureTopCluster,clojureSexpLevel0
234+
235+
syn region clojurePattern start=/L\=\#"/ skip=/\\\\\|\\"/ end=/"/
236+
237+
" FIXME: Matching of 'comment' is broken. It seems we can't nest
238+
" the different highlighting items, when they share the same end
239+
" pattern.
240+
" See also: https://bitbucket.org/kotarak/vimclojure/issue/87/comment-is-highlighted-incorrectly
241+
"
242+
"syn region clojureCommentSexp start="(" end=")" transparent contained contains=clojureCommentSexp
243+
"syn region clojureComment matchgroup=clojureParen0 start="(comment"rs=s+1 matchgroup=clojureParen0 end=")" contains=clojureTopCluster
244+
syn match clojureComment "comment"
245+
syn region clojureComment start="#!" end="\n"
246+
syn match clojureComment "#_"
247+
248+
syn sync fromstart
249+
250+
if version >= 600
251+
command -nargs=+ HiLink highlight default link <args>
252+
else
253+
command -nargs=+ HiLink highlight link <args>
254+
endif
255+
256+
HiLink clojureConstant Constant
257+
HiLink clojureBoolean Boolean
258+
HiLink clojureCharacter Character
259+
HiLink clojureKeyword Operator
260+
HiLink clojureNumber Number
261+
HiLink clojureString String
262+
HiLink clojurePattern Constant
263+
264+
HiLink clojureVariable Identifier
265+
HiLink clojureCond Conditional
266+
HiLink clojureDefine Define
267+
HiLink clojureException Exception
268+
HiLink clojureFunc Function
269+
HiLink clojureMacro Macro
270+
HiLink clojureRepeat Repeat
271+
272+
HiLink clojureQuote Special
273+
HiLink clojureUnquote Special
274+
HiLink clojureDispatch Special
275+
HiLink clojureAnonArg Special
276+
HiLink clojureVarArg Special
277+
HiLink clojureSpecial Special
278+
279+
HiLink clojureComment Comment
280+
HiLink clojureTodo Todo
281+
282+
HiLink clojureError Error
283+
284+
HiLink clojureParen0 Delimiter
285+
286+
if !exists("g:vimclojure#ParenRainbowColorsDark")
287+
if exists("g:vimclojure#ParenRainbowColors")
288+
let g:vimclojure#ParenRainbowColorsDark =
289+
\ g:vimclojure#ParenRainbowColors
290+
else
291+
let g:vimclojure#ParenRainbowColorsDark = {
292+
\ '1': 'ctermfg=yellow guifg=orange1',
293+
\ '2': 'ctermfg=green guifg=yellow1',
294+
\ '3': 'ctermfg=cyan guifg=greenyellow',
295+
\ '4': 'ctermfg=magenta guifg=green1',
296+
\ '5': 'ctermfg=red guifg=springgreen1',
297+
\ '6': 'ctermfg=yellow guifg=cyan1',
298+
\ '7': 'ctermfg=green guifg=slateblue1',
299+
\ '8': 'ctermfg=cyan guifg=magenta1',
300+
\ '9': 'ctermfg=magenta guifg=purple1'
301+
\ }
302+
endif
303+
endif
304+
305+
if !exists("g:vimclojure#ParenRainbowColorsLight")
306+
if exists("g:vimclojure#ParenRainbowColors")
307+
let g:vimclojure#ParenRainbowColorsLight =
308+
\ g:vimclojure#ParenRainbowColors
309+
else
310+
let g:vimclojure#ParenRainbowColorsLight = {
311+
\ '1': 'ctermfg=darkyellow guifg=orangered3',
312+
\ '2': 'ctermfg=darkgreen guifg=orange2',
313+
\ '3': 'ctermfg=blue guifg=yellow3',
314+
\ '4': 'ctermfg=darkmagenta guifg=olivedrab4',
315+
\ '5': 'ctermfg=red guifg=green4',
316+
\ '6': 'ctermfg=darkyellow guifg=paleturquoise3',
317+
\ '7': 'ctermfg=darkgreen guifg=deepskyblue4',
318+
\ '8': 'ctermfg=blue guifg=darkslateblue',
319+
\ '9': 'ctermfg=darkmagenta guifg=darkviolet'
320+
\ }
321+
endif
322+
endif
323+
324+
function! VimClojureSetupParenRainbow()
325+
if &background == "dark"
326+
let colors = g:vimclojure#ParenRainbowColorsDark
327+
else
328+
let colors = g:vimclojure#ParenRainbowColorsLight
329+
endif
330+
331+
for [level, color] in items(colors)
332+
execute "highlight clojureParen" . level . " " . color
333+
endfor
334+
endfunction
335+
336+
if vimclojure#ParenRainbow != 0
337+
call VimClojureSetupParenRainbow()
338+
339+
augroup VimClojureSyntax
340+
au!
341+
autocmd ColorScheme * if &ft == "clojure" | call VimClojureSetupParenRainbow() | endif
342+
augroup END
343+
else
344+
HiLink clojureParen1 clojureParen0
345+
HiLink clojureParen2 clojureParen0
346+
HiLink clojureParen3 clojureParen0
347+
HiLink clojureParen4 clojureParen0
348+
HiLink clojureParen5 clojureParen0
349+
HiLink clojureParen6 clojureParen0
350+
HiLink clojureParen7 clojureParen0
351+
HiLink clojureParen8 clojureParen0
352+
HiLink clojureParen9 clojureParen0
353+
endif
354+
355+
delcommand HiLink
356+
357+
let b:current_syntax = "clojure"

0 commit comments

Comments
 (0)