23466
|
1 " Vim syntax file
|
|
2 " Language: S-expressions as used in Sexplib
|
|
3 " Filenames: *.sexp
|
|
4 " Maintainers: Markus Mottl <markus.mottl@gmail.com>
|
|
5 " URL: https://github.com/ocaml/vim-ocaml
|
|
6 " Last Change: 2020 Dec 31 - Updated header for Vim contribution (MM)
|
|
7 " 2017 Apr 11 - Improved matching of negative numbers (MM)
|
|
8 " 2012 Jun 20 - Fixed a block comment highlighting bug (MM)
|
|
9
|
|
10 " For version 5.x: Clear all syntax items
|
|
11 " For version 6.x: Quit when a syntax file was already loaded
|
|
12 if version < 600
|
|
13 syntax clear
|
|
14 elseif exists("b:current_syntax") && b:current_syntax == "sexplib"
|
|
15 finish
|
|
16 endif
|
|
17
|
|
18 " Sexplib is case sensitive.
|
|
19 syn case match
|
|
20
|
|
21 " Comments
|
|
22 syn keyword sexplibTodo contained TODO FIXME XXX NOTE
|
|
23 syn region sexplibBlockComment matchgroup=sexplibComment start="#|" matchgroup=sexplibComment end="|#" contains=ALLBUT,sexplibQuotedAtom,sexplibUnquotedAtom,sexplibEncl,sexplibComment
|
|
24 syn match sexplibSexpComment "#;" skipwhite skipempty nextgroup=sexplibQuotedAtomComment,sexplibUnquotedAtomComment,sexplibListComment,sexplibComment
|
|
25 syn region sexplibQuotedAtomComment start=+"+ skip=+\\\\\|\\"+ end=+"+ contained
|
|
26 syn match sexplibUnquotedAtomComment /\([^;()" \t#|]\|#[^;()" \t|]\||[^;()" \t#]\)[^;()" \t]*/ contained
|
|
27 syn region sexplibListComment matchgroup=sexplibComment start="(" matchgroup=sexplibComment end=")" contained contains=ALLBUT,sexplibEncl,sexplibString,sexplibQuotedAtom,sexplibUnquotedAtom,sexplibTodo,sexplibNumber,sexplibFloat
|
|
28 syn match sexplibComment ";.*" contains=sexplibTodo
|
|
29
|
|
30 " Atoms
|
|
31 syn match sexplibUnquotedAtom /\([^;()" \t#|]\|#[^;()" \t|]\||[^;()" \t#]\)[^;()" \t]*/
|
|
32 syn region sexplibQuotedAtom start=+"+ skip=+\\\\\|\\"+ end=+"+
|
|
33 syn match sexplibNumber "-\=\<\d\(_\|\d\)*[l|L|n]\?\>"
|
|
34 syn match sexplibNumber "-\=\<0[x|X]\(\x\|_\)\+[l|L|n]\?\>"
|
|
35 syn match sexplibNumber "-\=\<0[o|O]\(\o\|_\)\+[l|L|n]\?\>"
|
|
36 syn match sexplibNumber "-\=\<0[b|B]\([01]\|_\)\+[l|L|n]\?\>"
|
|
37 syn match sexplibFloat "-\=\<\d\(_\|\d\)*\.\?\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>"
|
|
38
|
|
39 " Lists
|
|
40 syn region sexplibEncl transparent matchgroup=sexplibEncl start="(" matchgroup=sexplibEncl end=")" contains=ALLBUT,sexplibParenErr
|
|
41
|
|
42 " Errors
|
|
43 syn match sexplibUnquotedAtomErr /\([^;()" \t#|]\|#[^;()" \t|]\||[^;()" \t#]\)[^;()" \t]*\(#|\||#\)[^;()" \t]*/
|
|
44 syn match sexplibParenErr ")"
|
|
45
|
|
46 " Synchronization
|
|
47 syn sync minlines=50
|
|
48 syn sync maxlines=500
|
|
49
|
|
50 " Define the default highlighting.
|
|
51 " For version 5.7 and earlier: only when not done already
|
|
52 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
53 if version >= 508 || !exists("did_sexplib_syntax_inits")
|
|
54 if version < 508
|
|
55 let did_sexplib_syntax_inits = 1
|
|
56 command -nargs=+ HiLink hi link <args>
|
|
57 else
|
|
58 command -nargs=+ HiLink hi def link <args>
|
|
59 endif
|
|
60
|
|
61 HiLink sexplibParenErr Error
|
|
62 HiLink sexplibUnquotedAtomErr Error
|
|
63
|
|
64 HiLink sexplibComment Comment
|
|
65 HiLink sexplibSexpComment Comment
|
|
66 HiLink sexplibQuotedAtomComment Include
|
|
67 HiLink sexplibUnquotedAtomComment Comment
|
|
68 HiLink sexplibBlockComment Comment
|
|
69 HiLink sexplibListComment Comment
|
|
70
|
|
71 HiLink sexplibBoolean Boolean
|
|
72 HiLink sexplibCharacter Character
|
|
73 HiLink sexplibNumber Number
|
|
74 HiLink sexplibFloat Float
|
|
75 HiLink sexplibUnquotedAtom Identifier
|
|
76 HiLink sexplibEncl Identifier
|
|
77 HiLink sexplibQuotedAtom Keyword
|
|
78
|
|
79 HiLink sexplibTodo Todo
|
|
80
|
|
81 HiLink sexplibEncl Keyword
|
|
82
|
|
83 delcommand HiLink
|
|
84 endif
|
|
85
|
|
86 let b:current_syntax = "sexplib"
|
|
87
|
|
88 " vim: ts=8
|