xref: /vim-8.2.3635/runtime/syntax/sexplib.vim (revision 7e6a515e)
1" Vim syntax file
2" Language:     S-expressions as used in Sexplib
3" Filenames:    *.sexp
4" Maintainers:  Markus Mottl      <[email protected]>
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
12if version < 600
13  syntax clear
14elseif exists("b:current_syntax") && b:current_syntax == "sexplib"
15  finish
16endif
17
18" Sexplib is case sensitive.
19syn case match
20
21" Comments
22syn keyword  sexplibTodo contained TODO FIXME XXX NOTE
23syn region   sexplibBlockComment matchgroup=sexplibComment start="#|" matchgroup=sexplibComment end="|#" contains=ALLBUT,sexplibQuotedAtom,sexplibUnquotedAtom,sexplibEncl,sexplibComment
24syn match    sexplibSexpComment "#;" skipwhite skipempty nextgroup=sexplibQuotedAtomComment,sexplibUnquotedAtomComment,sexplibListComment,sexplibComment
25syn region   sexplibQuotedAtomComment start=+"+ skip=+\\\\\|\\"+ end=+"+ contained
26syn match    sexplibUnquotedAtomComment /\([^;()" \t#|]\|#[^;()" \t|]\||[^;()" \t#]\)[^;()" \t]*/ contained
27syn region   sexplibListComment matchgroup=sexplibComment start="(" matchgroup=sexplibComment end=")" contained contains=ALLBUT,sexplibEncl,sexplibString,sexplibQuotedAtom,sexplibUnquotedAtom,sexplibTodo,sexplibNumber,sexplibFloat
28syn match    sexplibComment ";.*" contains=sexplibTodo
29
30" Atoms
31syn match    sexplibUnquotedAtom /\([^;()" \t#|]\|#[^;()" \t|]\||[^;()" \t#]\)[^;()" \t]*/
32syn region   sexplibQuotedAtom    start=+"+ skip=+\\\\\|\\"+ end=+"+
33syn match    sexplibNumber        "-\=\<\d\(_\|\d\)*[l|L|n]\?\>"
34syn match    sexplibNumber        "-\=\<0[x|X]\(\x\|_\)\+[l|L|n]\?\>"
35syn match    sexplibNumber        "-\=\<0[o|O]\(\o\|_\)\+[l|L|n]\?\>"
36syn match    sexplibNumber        "-\=\<0[b|B]\([01]\|_\)\+[l|L|n]\?\>"
37syn match    sexplibFloat         "-\=\<\d\(_\|\d\)*\.\?\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>"
38
39" Lists
40syn region   sexplibEncl transparent matchgroup=sexplibEncl start="(" matchgroup=sexplibEncl end=")" contains=ALLBUT,sexplibParenErr
41
42" Errors
43syn match    sexplibUnquotedAtomErr /\([^;()" \t#|]\|#[^;()" \t|]\||[^;()" \t#]\)[^;()" \t]*\(#|\||#\)[^;()" \t]*/
44syn match    sexplibParenErr ")"
45
46" Synchronization
47syn sync minlines=50
48syn 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
53if 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
84endif
85
86let b:current_syntax = "sexplib"
87
88" vim: ts=8
89