-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.miniyaml.js
91 lines (89 loc) · 2.52 KB
/
source.miniyaml.js
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/OpenRA/atom-miniyaml>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: [],
extensionsWithDot: ['.yaml', '.yml'],
names: ['miniyaml'],
patterns: [{include: '#comment'}, {include: '#node'}],
repository: {
'block-pair': {
match: '^\\t*(\\S+?)(?=@|:)',
name: 'entity.name.tag.yaml',
patterns: [{include: '#node-identifier'}]
},
comment: {
begin: '(?<=^|\\s)#(?!{)',
beginCaptures: {0: {name: 'punctuation.definition.comment.yaml'}},
end: '$',
name: 'comment.line.number-sign.yaml'
},
constants: {
match: '(?::\\s)(true|false|True|False|TRUE|FALSE|~)(?=\\s*$)',
name: 'constant.language.yaml'
},
node: {
patterns: [
{include: '#node-removal'},
{include: '#block-pair'},
{include: '#node-identifier'},
{include: '#scalar-content'}
]
},
'node-identifier': {match: '(?<=\\S)(@\\S+)(?=:\\s)', name: 'support.yaml'},
'node-removal': {match: '^\\t+(-.+?)(?=@|:\\s)', name: 'entity.yaml'},
numeric: {
patterns: [
{
match: '(?::\\s)[-+]?[0-9]+(?=\\s*($|#(?!#{)))',
name: 'constant.numeric.integer.yaml'
},
{
match: '(?::\\s)0o[0-7]+(?=\\s*($|#(?!#{)))',
name: 'constant.numeric.octal.yaml'
},
{
match: '(?::\\s)0x[0-9a-fA-F]+(?=\\s*($|#(?!#{)))',
name: 'constant.numeric.hexadecimal.yaml'
},
{
match:
'(?::\\s)[-+]?(.[0-9]+|[0-9]+(.[0-9]*)?)([eE][-+]?[0-9]+)?(?=\\s*($|#(?!#{)))',
name: 'constant.numeric.float.yaml'
},
{
match: '(?::\\s)[-+]?(.inf|.Inf|.INF)(?=\\s*($|#(?!#{)))',
name: 'constant.numeric.float.yaml'
},
{
match: '(?::\\s)(.nan|.NaN|.NAN)(?=\\s*($|#(?!#{)))',
name: 'constant.numeric.float.yaml'
}
]
},
'scalar-content': {
patterns: [
{include: '#comment'},
{include: '#constants'},
{include: '#numeric'},
{include: '#strings'}
]
},
strings: {
patterns: [
{
match: '[^\\s"\'\\n](?!\\s*#(?!{))([^#\\n]|((?<!\\s)#))*',
name: 'string.unquoted.yaml'
}
]
}
},
scopeName: 'source.miniyaml'
}
export default grammar