/
source.dotenv.js
148 lines (147 loc) · 4.61 KB
/
source.dotenv.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
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
147
148
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Alhadis/language-etc>
// and licensed `isc`.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.env'],
injections: {
'source.dotenv meta.field.rhs string - string.quoted.single': {
patterns: [
{
captures: {
1: {name: 'punctuation.section.embedded.begin.dotenv'},
2: {name: 'constant.language.environment.variable.dotenv'},
3: {name: 'punctuation.section.embedded.end.dotenv'}
},
match: '(?<!\\\\)(\\${)(.*?)(?<!\\\\)(})',
name: 'source.shell.embedded.dotenv'
},
{
captures: {1: {name: 'punctuation.definition.variable.dotenv'}},
match: '(?<!\\\\)(\\$)[a-zA-Z0-9_]+',
name: 'entity.name.variable.dotenv'
},
{
captures: {
1: {name: 'punctuation.section.embedded.begin.dotenv'},
2: {patterns: [{include: 'source.shell'}]},
3: {name: 'punctuation.section.embedded.end.dotenv'}
},
match: '(?<!\\\\)(\\$\\()(.*?)(?<!\\\\)(\\))',
name: 'source.shell.embedded.dotenv'
}
]
},
'source.dotenv meta.field.rhs string.unquoted': {
patterns: [
{
begin: '(?<=\\S)[ \\t]+(#)',
captures: {1: {name: 'punctuation.definition.comment.dotenv'}},
end: '(?=$)',
name: 'comment.line.number-sign.inline.dotenv'
}
]
}
},
names: ['dotenv'],
patterns: [{include: '#main'}],
repository: {
comment: {
begin: '^([ \\t]*)(?=#)',
beginCaptures: {
1: {name: 'punctuation.whitespace.leading.comment.dotenv'}
},
end: '(?!\\G)',
patterns: [
{
begin: '\\G(#)',
beginCaptures: {1: {name: 'punctuation.definition.comment.dotenv'}},
end: '$',
name: 'comment.line.number-sign.dotenv'
}
]
},
field: {
begin: '^(([ \\t]*)(?:(export)\\s+)?([-\\w.]+)\\s*)(=|:)',
beginCaptures: {
1: {name: 'meta.field.lhs.dotenv'},
2: {name: 'punctuation.whitespace.leading.field.dotenv'},
3: {name: 'storage.modifier.export.dotenv'},
4: {name: 'variable.assignment.environment.dotenv'},
5: {name: 'keyword.operator.assignment.key-value.dotenv'}
},
contentName: 'meta.field.rhs.dotenv',
end: '(?!\\G)',
name: 'meta.field.dotenv',
patterns: [
{
match: '\\G[ \\t]+$',
name: 'punctuation.whitespace.trailing.empty-value.dotenv'
},
{
begin: '\\G[ \\t]*(?=("|\')(?:[^\\\\"\']|(?!\\1)["\']|\\\\.)*+\\1$)',
end: '(?!\\G)',
patterns: [{include: '#strings'}]
},
{
begin: '\\G[ \\t]*(?!"|\')(?=\\S)',
contentName: 'string.unquoted.field.dotenv',
end: '([ \\t]*)$',
endCaptures: {1: {name: 'punctuation.whitespace.trailing.dotenv'}}
}
]
},
main: {patterns: [{include: '#comment'}, {include: '#field'}]},
strings: {
patterns: [
{
begin: '\\G"',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.dotenv'}
},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.env.dotenv'}},
name: 'string.quoted.double.dotenv',
patterns: [
{
captures: {
1: {name: 'punctuation.definition.escape.backslash.dotenv'}
},
match: '(\\\\)n',
name: 'constant.character.escape.newline.dotenv'
},
{
captures: {
1: {name: 'punctuation.definition.escape.backslash.dotenv'}
},
match: '(\\\\)"',
name: 'constant.character.escape.quote.dotenv'
}
]
},
{
begin: "\\G'",
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.dotenv'}
},
end: "'",
endCaptures: {0: {name: 'punctuation.definition.string.env.dotenv'}},
name: 'string.quoted.single.dotenv',
patterns: [
{
captures: {
1: {name: 'punctuation.definition.escape.backslash.dotenv'}
},
match: "(\\\\)'",
name: 'constant.character.escape.quote.dotenv'
}
]
}
]
}
},
scopeName: 'source.dotenv'
}
export default grammar