-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.redirects.js
67 lines (65 loc) · 1.86 KB
/
source.redirects.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Nixinova/NovaGrammars>
// and licensed `isc`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: [],
names: ['redirect-rules', 'redirects'],
patterns: [{include: '#main'}],
repository: {
code: {
match: '(?<==)[a-z]{2}(?:-[A-Z]{2})?(?=\\s|$)',
name: 'string.unquoted.code.redirects'
},
comment: {
begin: '#',
beginCaptures: {0: {name: 'punctuation.definition.comment.redirects'}},
end: '$',
name: 'comment.line.hash.redirects'
},
main: {
patterns: [
{include: '#comment'},
{include: '#uri'},
{include: '#query'},
{include: '#number'},
{include: '#code'},
{include: '#punct'},
{include: '#text'}
]
},
number: {
captures: {
1: {name: 'constant.numeric.integer.redirects'},
2: {name: 'constant.character.force.redirects'}
},
match: '(\\d+)(!)?'
},
punct: {
patterns: [
{match: ':|=', name: 'punctuation.accessor.redirects'},
{match: ',(?!\\s)', name: 'punctuation.separator.redirects'}
]
},
query: {
match: '[^\\s]+(?==)',
name: 'keyword.other.query-selector.redirects'
},
splat: {match: ':\\w+', name: 'variable.other.splat.redirects'},
text: {match: '(?<==)[^\\s]+', name: 'string.unquoted.text.redirects'},
uri: {
begin: '(?:[a-z]+:)?\\/',
end: '[\\s$]',
name: 'string.unquoted.uri.redirects',
patterns: [{include: '#wildcard'}, {include: '#splat'}]
},
wildcard: {match: '\\*', name: 'constant.character.wildcard.redirects'}
},
scopeName: 'source.redirects'
}
export default grammar