-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
go.mod.js
120 lines (118 loc) · 3.22 KB
/
go.mod.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/golang/vscode-go>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: [],
names: [
'go-mod',
'go-module',
'go-work',
'go-workspace',
'go.mod',
'go.work'
],
patterns: [
{include: '#comments'},
{include: '#directive'},
{include: '#invalid'}
],
repository: {
arguments: {
patterns: [
{include: '#comments'},
{include: '#double_quoted_string'},
{include: '#raw_quoted_string'},
{include: '#operator'},
{include: '#semver'},
{include: '#unquoted_string'}
]
},
comments: {
patterns: [
{
begin: '//',
beginCaptures: {0: {name: 'punctuation.definition.comment.go.mod'}},
end: '$',
name: 'comment.line.double-slash.go.mod'
}
]
},
directive: {
patterns: [
{
begin: '(\\w+)\\s*\\(',
beginCaptures: {1: {name: 'keyword.go.mod'}},
end: '\\)',
patterns: [{include: '#arguments'}]
},
{
captures: {
1: {name: 'keyword.go.mod'},
2: {patterns: [{include: '#arguments'}]}
},
match: '(\\w+)\\s*(.*)'
}
]
},
double_quoted_string: {
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.go.mod'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.go.mod'}},
name: 'string.quoted.double',
patterns: [
{include: '#string_escaped_char'},
{include: '#string_placeholder'}
]
},
invalid: {match: '.*', name: 'invalid.illegal.unknown.go.mod'},
operator: {match: '(=>)', name: 'operator.go.mod'},
raw_quoted_string: {
begin: '`',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.go.mod'}},
end: '`',
endCaptures: {0: {name: 'punctuation.definition.string.end.go.mod'}},
name: 'string.quoted.raw',
patterns: [{include: '#string_placeholder'}]
},
semver: {
match:
'v(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[\\da-z-]+(?:\\.[\\da-z-]+)*)?(?:\\+[\\da-z-]+(?:\\.[\\da-z-]+)*)?',
name: 'constant.language.go.mod'
},
string_escaped_char: {
patterns: [
{
match:
'\\\\([0-7]{3}|[abfnrtv\\\\\'"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})',
name: 'constant.character.escape.go.mod'
},
{
match: '\\\\[^0-7xuUabfnrtv\\\'"]',
name: 'invalid.illegal.unknown-escape.go.mod'
}
]
},
string_placeholder: {
patterns: [
{
match:
'%(\\[\\d+\\])?([\\+#\\-0\\x20]{,2}((\\d+|\\*)?(\\.?(\\d+|\\*|(\\[\\d+\\])\\*?)?(\\[\\d+\\])?)?))?[vT%tbcdoqxXUbeEfFgGsp]',
name: 'constant.other.placeholder.go.mod'
}
]
},
unquoted_string: {
match: '([^\\s/]|/(?!/))+',
name: 'string.unquoted.go.mod'
}
},
scopeName: 'go.mod'
}
export default grammar