forked from tonsky/Clojure-Sublimed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EDN (Sublime Clojure).sublime-syntax
146 lines (134 loc) · 4.78 KB
/
EDN (Sublime Clojure).sublime-syntax
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
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: EDN (Sublime Clojure)
file_extensions:
- edn
scope: source.edn
variables:
wsb: '(?<=^|[\s,()\[\]{}"]|#_)' # Clojure: add ~ @ ~@ ' `
wse: '(?=$|[\s,()\[\]{}";])'
nwse: '[^\s,()\[\]{}";]'
sym_head: '[\p{Alpha}*!_?$%&=<>]'
sym_head_lax: '[\p{Alpha}*!_?$%&=<>''\-+.#:]'
sym_body: '[\p{Alpha}*!_?$%&=<>''\-+.#:0-9]'
ns_symbol: '(?:[\-+.]|[\-+.]{{sym_head_lax}}{{sym_body}}*|{{sym_head}}{{sym_body}}*)'
symbol: '(?:/|{{ns_symbol}})'
kw_head: '[\p{Alpha}*!_?$%&=<>''\-+.#0-9]'
kw_body: '[\p{Alpha}*!_?$%&=<>''\-+.#0-9:]'
keyword: '{{kw_head}}{{kw_body}}*'
contexts:
main:
- include: string
- include: character
- include: comment
- include: keyword
- include: constant
- include: symbol
- include: integer
- include: float
- include: ratio
- include: tag
- include: brackets
- include: stray-brackets
- match: ','
scope: punctuation.definition.comma.edn
constant:
- match: '{{wsb}}(nil|true|false){{wse}}'
scope: constant.language.edn
string:
- match: '"'
scope: punctuation.definition.string.begin.edn
push:
- meta_scope: string.quoted.double.edn
- match: '(\\)(u\h{4}|b|t|n|f|r|"|''|\\|[0-3]?[0-7]{1,2})|((\\).)'
scope: constant.character.escape.edn
captures:
1: punctuation.definition.character.escape.begin.edn
3: invalid.illegal.escape.string.edn
4: punctuation.definition.character.escape.begin.edn
- match: '"'
scope: punctuation.definition.string.end.edn
pop: true
character:
- match: '{{wsb}}((\\)(u\h{4}|o[0-3]?[0-7]{1,2}|newline|tab|space|backspace|formfeed|return|[^\s]){{wse}}|((\\){{nwse}}*))'
scope: constant.character.edn
captures:
2: punctuation.definition.character.begin.edn
4: invalid.illegal.character.edn
5: punctuation.definition.character.begin.edn
comment: # TODO Clojure (comment)
- match: '(;+).*$'
scope: comment.line.semicolon.edn
captures:
1: punctuation.definition.comment.edn
- match: '#_'
scope: comment.block.edn punctuation.definition.comment.edn
symbol:
- match: '{{wsb}}(?:{{symbol}}|{{ns_symbol}}(/){{symbol}}){{wse}}'
scope: source.symbol.edn
captures:
1: punctuation.definition.symbol.namespace.edn
keyword:
- match: '{{wsb}}(:){{keyword}}(?:(/){{keyword}})?{{wse}}' # Clojure: ::keywords
scope: constant.other.keyword.edn
captures:
1: punctuation.definition.constant.begin.edn
2: punctuation.definition.constant.namespace.edn
integer:
- match: '{{wsb}}[+-]?(?:0|[1-9][0-9]*)(N)?{{wse}}'
scope: constant.numeric.integer.edn
captures:
1: punctuation.definition.integer.precision.edn
float:
- match: '{{wsb}}[+-]?(?:0|[1-9][0-9]*)(?:(M)|\.[0-9]*(M)?|[eE][+-]?[0-9]+(M)?|\.[0-9]*[eE][+-]?[0-9]+(M)?){{wse}}'
scope: constant.numeric.float.edn
captures:
1: punctuation.definition.float.precision.edn
2: punctuation.definition.float.precision.edn
3: punctuation.definition.float.precision.edn
4: punctuation.definition.float.precision.edn
- match: '{{wsb}}(##Inf|##-Inf|##NaN){{wse}}'
scope: constant.numeric.float.edn
ratio:
- match: '{{wsb}}[+-]?(0|[1-9][0-9]*)/[1-9][0-9]*{{wse}}'
scope: constant.numeric.ratio.edn
tag:
- match: '{{wsb}}(#inst\s*"\d\d\d\d(?:-[01]\d(?:-[0123]\d(?:T[012]\d(?::[012345]\d(?::[0123456]\d(?:[.]\d{1,9})?)?)?)?)?)?(?:Z|[-+][012]\d:[012345]\d)?"|(#inst\s*"[^"]*")){{wse}}'
scope: constant.other.instant.edn
captures:
2: invalid.illegal.instant.edn
- match: '{{wsb}}(#uuid\s*"\h{8}-\h{4}-\h{4}-\h{4}-\h{12}"|(#uuid\s*"[^"]*")){{wse}}'
scope: constant.other.uuid.edn
captures:
2: invalid.illegal.uuid.edn
- match: '{{wsb}}#(?![_#{])(?:{{symbol}}|{{ns_symbol}}(/){{symbol}}){{wse}}'
scope: storage.type.tag.edn
brackets:
- match: '#?\('
scope: punctuation.section.parens.begin.edn
push:
- meta_scope: meta.parens.edn
- match: \)
scope: punctuation.section.parens.end.edn
pop: true
- include: main
- match: \[
scope: punctuation.section.brackets.begin.edn
push:
- meta_scope: meta.brackets.edn
- match: \]
scope: punctuation.section.brackets.end.edn
pop: true
- include: main
- match: '#?\{'
scope: punctuation.section.braces.begin.edn
push:
- meta_scope: meta.braces.edn
- match: \}
scope: punctuation.section.braces.end.edn
pop: true
- include: main
stray-brackets:
- match: '[\]\)\}]'
scope: invalid.illegal.stray-bracket-end