generated from kachick/anylang-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkdl.yaml
64 lines (62 loc) · 1.93 KB
/
kdl.yaml
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
filetype: 'kdl'
detect:
filename: "\\.kdl"
rules:
# Punctuation
- symbol.operator: '='
- symbol.brackets: '[{}]'
# Strings
- constant.string:
start: '"'
end: '"'
skip: '(\\\\\|\\")'
rules:
- constant.specialChar: '\\u[[:xdigit:]]{1,6}'
- constant.specialChar: '\\[btnfr"\\]'
# Raw Strings
# These definitions are not correct, ideally `#` should be same count for both begin and end, but it should be programmable as captured \1
# In my understanding, this is a micro editor restriction. See https://github.com/zyedidia/micro/blob/21bb61c5ff3cd4cd11adbd521657df90d50f54c7/runtime/syntax/jsonnet.yaml#L61-L78
# So, I defined some typical cases here, supporting only for 0-3 "#"
- constant.string:
start: '\br"'
end: '"'
rules: []
- constant.string:
start: '\br#"'
end: '"#'
rules: []
- constant.string:
start: '\br##"'
end: '"##'
rules: []
- constant.string:
start: '\br###"'
end: '"###'
rules: []
# Integer
- constant.number: '[-+]?(\d+)'
# Float
- constant.number: '[-+]?(\d+)\.\d*'
# Boolean and inf, nan without sign
- constant.bool.true: '\btrue\b'
- constant.bool.false: '\bfalse\b'
# Comments
- comment:
start: '//'
end: '$'
rules:
- todo: '(TODO|FIXME|XXX|NOTE)'
# Slashdash comments
# https://github.com/kdl-org/kdl/blob/de1dbd2c330c9193b836499db241787484627c3b/SPEC.md#L77-L79
# vscode extension realizes this with lookahead and lookbehind, the regex feature cannot be used in micro
# https://github.com/kdl-org/vscode-kdl/blob/646d7b819d72b2f0d9dd05102a305506bafa3cf6/syntaxes/kdl.tmLanguage.json#L182-L199
# https://github.com/zyedidia/micro/issues/901#issuecomment-354931928
# So simplified it, it means this is inaccurate
- comment.block:
start: '^\s*/-'
end: '\s'
rules: []
- comment.block:
start: '/-{'
end: '}'
rules: []