Skip to content

Commit 32ed1bf

Browse files
committed
Add glob injections
1 parent 30a5384 commit 32ed1bf

File tree

8 files changed

+1378
-1
lines changed

8 files changed

+1378
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Then using multiple injection grammars that target those scopeNames and inject s
1818
Recommend the [Snippets Snippets](https://marketplace.visualstudio.com/items?itemName=RedCMD.snippets-snippets) extension
1919
![Example `schema.json`](images/Example-schema.png)
2020

21+
* Glob patterns within `"filenamePatterns"` and `"fileMatch"` for `package.json`
22+
![Example `package.json/filenamePatterns`](images/Example-filenamePatterns.png)
23+
2124

2225
## Known Issues
2326

169 KB
Loading

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@
9999
"source.json.embedded"
100100
]
101101
},
102+
{
103+
"scopeName": "source.json.package.glob",
104+
"path": "./syntaxes/glob.tmLanguage.json",
105+
"injectTo": [
106+
"source.json.comments.embedded",
107+
"source.json.embedded"
108+
]
109+
},
102110
{
103111
"scopeName": "source.json.package.scopes",
104112
"path": "./syntaxes/package-scopes.tmLanguage.json",

syntaxes/glob.tmLanguage.json

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/RedCMD/TmLanguage-Syntax-Highlighter/main/vscode.tmLanguage.schema.json",
3+
"name": "\"filenamePatterns\", \"fileMatch\" & \"workspaces\" inside `package.json` and \"include\", \"exclude\" & \"moduleTypes\" inside `tsconfig.json`",
4+
"comment": "https://code.visualstudio.com/docs/editor/glob-patterns",
5+
"scopeName": "source.json.package.glob",
6+
"injectionSelector": [
7+
"L:source.json.embedded .meta.embedded.contributes. .meta.embedded.languages. meta.structure.array.json .meta.embedded.filenamePatterns. meta.structure.array.json string.quoted.double.json -(meta.structure.dictionary.json meta.structure.dictionary.json meta.structure.dictionary.json meta.structure.dictionary.json) -(meta.structure.array.json meta.structure.array.json meta.structure.array.json) -meta.embedded.glob.json -comment",
8+
"L:source.json.embedded .meta.embedded.contributes. .meta.embedded.jsonValidation. meta.structure.array.json .meta.embedded.fileMatch. string.quoted.double.json -(meta.structure.dictionary.json meta.structure.dictionary.json meta.structure.dictionary.json meta.structure.dictionary.json) -(meta.structure.array.json meta.structure.array.json) -meta.embedded.glob.json -comment",
9+
"L:source.json.embedded .meta.embedded.workspaces. meta.structure.array.json string.quoted.double.json -(meta.structure.dictionary.json meta.structure.dictionary.json) -(meta.structure.array.json meta.structure.array.json) -meta.embedded.glob.json -comment",
10+
"L:source.json.embedded .meta.embedded.workspaces. .meta.embedded.packages. meta.structure.array.json string.quoted.double.json -(meta.structure.dictionary.json meta.structure.dictionary.json meta.structure.dictionary.json) -(meta.structure.array.json meta.structure.array.json) -meta.embedded.glob.json -comment",
11+
"L:source.json.comments.embedded .meta.embedded.configurations. meta.structure.array.json.comments string.quoted.double.json.comments (.meta.embedded.skipFiles. | .meta.embedded.outFiles.) -(meta.structure.dictionary.json.comments meta.structure.dictionary.json.comments meta.structure.dictionary.json.comments) -(meta.structure.array.json.comments meta.structure.array.json.comments meta.structure.array.json.comments) -meta.embedded.glob.json -comment",
12+
"L:source.json.comments.embedded meta.structure.array.json.comments string.quoted.double.json.comments (.meta.embedded.include. | .meta.embedded.exclude.) -(meta.structure.dictionary.json.comments meta.structure.dictionary.json.comments) -(meta.structure.array.json.comments meta.structure.array.json.comments) -meta.embedded.glob.json -comment",
13+
"L:source.json.comments.embedded .meta.embedded.ts-node. .meta.embedded.moduleTypes. meta.structure.dictionary.json.comments support.type.property-name.json.comments -(meta.structure.dictionary.json.comments meta.structure.dictionary.json.comments meta.structure.dictionary.json.comments meta.structure.dictionary.json.comments) -meta.structure.array.json.comments -meta.embedded.glob.json -comment"
14+
],
15+
"patterns": [
16+
{
17+
"begin": "(?<=\")\\G(?=(?>[^\\x00-\\x1F\"\\\\]++|\\\\.)++\")",
18+
"end": "(?=\"|$)",
19+
"name": "meta.embedded.glob.json",
20+
"contentName": "string.regexp.glob.json",
21+
"patterns": [ { "include": "#glob" } ]
22+
}
23+
],
24+
"repository": {
25+
"glob": {
26+
"patterns": [
27+
{
28+
"match": "(\\\\?)/",
29+
"name": "keyword.separator.path.glob-split.glob.json",
30+
"captures": { "1": { "name": "constant.character.escape.glob.json" } }
31+
},
32+
{
33+
"match": "(\\*\\*)(\\**)|(\\*)",
34+
"name": "keyword.operator.quantifier.regexp.glob.json",
35+
"captures": {
36+
"1": { "name": "punctuation.definition.globstar.glob.json" },
37+
"2": { "name": "comment.globstar.glob.json" },
38+
"3": { "name": "punctuation.definition.star.glob.json" }
39+
}
40+
},
41+
{
42+
"match": "\\?",
43+
"name": "keyword.operator.quantifier.regexp.glob.json"
44+
},
45+
{
46+
"match": "}",
47+
"name": "comment.group.glob.json"
48+
},
49+
{
50+
"begin": "{",
51+
"end": "}|(?=\")|$",
52+
"beginCaptures": { "0": { "name": "punctuation.definition.group.begin.glob.json" } },
53+
"endCaptures": { "0": { "name": "punctuation.definition.group.end.glob.json" } },
54+
"name": "meta.embedded.group.glob.json",
55+
"contentName": "string.regexp.glob.json",
56+
"patterns": [
57+
{
58+
"match": ",",
59+
"name": "keyword.operator.separator.comma.glob.json punctuation.separator.comma.glob.string"
60+
},
61+
{ "include": "#glob" }
62+
]
63+
},
64+
{
65+
"match": "]",
66+
"name": "meta.embedded.character-class.glob.json",
67+
"captures": { "0": { "name": "invalid.illegal.character-class.end.glob.json" } }
68+
},
69+
{
70+
"begin": "(\\[)((?:\\\\?/)*)([!^]?)((?:\\\\?/)*)",
71+
"end": "(?!\\G)]|(?=\")|$",
72+
"beginCaptures": {
73+
"1": { "name": "punctuation.definition.character-class.begin.glob.json" },
74+
"2": { "patterns": [ { "include": "#glob-split" } ] },
75+
"3": { "name": "keyword.operator.negation.glob.json" },
76+
"4": { "patterns": [ { "include": "#glob-split" } ] }
77+
},
78+
"endCaptures": { "0": { "name": "punctuation.definition.character-class.end.glob.json" } },
79+
"name": "meta.embedded.character-class.glob.json",
80+
"contentName": "constant.other.character-class.set.regexp.string.glob.json",
81+
"patterns": [
82+
{ "include": "#glob-split" },
83+
{
84+
"match": "[0-9]-[0-9]",
85+
"name": "constant.numeric.character-class.range.glob.json"
86+
},
87+
{
88+
"match": "[a-z]-[a-z]|[A-Z]-[A-Z]",
89+
"name": "variable.other.constant.character-class.range.glob.json"
90+
},
91+
{
92+
"comment": "Character Class Range contains glob-split character / ",
93+
"match": "[ -.]-(?:[0-\\[^-~]|(?=\\\\))",
94+
"name": "invalid.illegal.character-class.range.glob-split.glob.json"
95+
},
96+
{
97+
"match": "(?:(\\\\)[\\\\\"]|[^\\\\/])((?:\\\\?/)*)-((?:\\\\?/)*)(?:(\\\\)[\\\\\"]|[^]\\\\\"/])",
98+
"captures": {
99+
"0": { "name": "support.class.range.string.glob.json" },
100+
"1": { "name": "constant.character.escape.backslash.glob.json" },
101+
"2": { "patterns": [ { "include": "#glob-split" } ] },
102+
"3": { "patterns": [ { "include": "#glob-split" } ] },
103+
"4": { "name": "constant.character.escape.backslash.glob.json" }
104+
},
105+
"name": "constant.other.character-class.range.glob.json"
106+
},
107+
{
108+
"match": "(\\\\?)\\\\",
109+
"captures": { "1": { "name": "constant.character.escape.glob.json" } }
110+
},
111+
{ "include": "source.json.embedded#stringcontent" }
112+
]
113+
},
114+
{
115+
"match": "(\\\\?)\\\\",
116+
"captures": { "1": { "name": "constant.character.escape.glob.json" } }
117+
},
118+
{ "include": "source.json.embedded#stringcontent" }
119+
]
120+
},
121+
"glob-split": {
122+
"comment": "glob-split / is ignored inside square brackets https://man7.org/linux/man-pages/man7/glob.7.html",
123+
"match": "(\\\\?)/",
124+
"name": "comment.invalid.illegal.glob-split.glob.json",
125+
"captures": { "1": { "name": "constant.character.escape.glob.json" } }
126+
}
127+
}
128+
}

syntaxes/tests/JSON/package.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://www.schemastore.org/package",
23
"scripts": {
34
"build": "npm run compile && npm run compile-web && npm run generate-wasm && node ./out/Onigmo/moveOnigmo",
45
"package": "vsce package",
@@ -12,6 +13,69 @@
1213
"contributes": {
1314
"languages": [
1415
{
16+
"filenamePatterns": [
17+
"**/syntaxes/*inject*.json",
18+
"**/syntaxes/*codeblock*.json",
19+
"**/syntaxes/*code?block*.json",
20+
"**/syntaxes/*.tmLanguage.json",
21+
"**/syntaxes/*.tmLanguage copy{, [0-9]*}.json",
22+
"**/syntaxes/*.tmLanguage{, copy} - Copy{, ([0-9]*)}{, - Copy*}.json",
23+
"**/grammars/*inject*.json",
24+
"**/grammars/*codeblock*.json",
25+
"**/grammars/*code?block*.json",
26+
"**/grammars/*.tmLanguage.json",
27+
"**/grammars/*.tmLanguage copy{, [0-9]*}.json",
28+
"**/grammars/*.tmLanguage{, copy} - Copy{, ([0-9]*)}{, - Copy*}.json",
29+
"* ** *** {*} {**} {***} {*,**} [*] [**] [***]",
30+
"? {?} {?,?} [?]",
31+
"[\/ / /-/ ] [/]] [/^\/]/] []a[!] [A-Fa-f0-9] []-] [--0] [--0] [.-0] [---] [!]a-] [[?*\\]",
32+
"**/{Crusader Kings III,CK,CK3,1158310}/**/*.{txt,gui,info}",
33+
"**/{Europa Universalis IV,EU,EU4,236850}/**/*.{txt,gui}",
34+
"**/{Hearts of Iron IV,HOI,HOI4,394360}/**/*.{txt,gui}",
35+
"**/{Victoria 3,VIC,VIC3,529340}/**/*.{txt,gui,info}",
36+
"**/*requirements*.{txt, in}",
37+
"**/*constraints*.txt",
38+
"**/requirements/*.{txt,in}",
39+
"**/constraints/*.txt",
40+
"@vcode-tm-log-*-*-*-*-*.txt",
41+
"**/*.[w.-]+",
42+
"**/([w.-]+)/?",
43+
"{**/*?[w.-]+/?(,**/*?[w.-]+/?)*}",
44+
"{**/*?[w.-]+(/(**)?)?(,**/*?[w.-]+(/(**)?)?)*}",
45+
"**((/[w.-]+)+)/?",
46+
"([w.-]+(/[w.-]+)*)/?",
47+
"Dockerfile.*",
48+
"Containerfile.*",
49+
"**/rebase-merge/done",
50+
"**/.config/git/config",
51+
"**/.git/config",
52+
"**/User/snippets/*.json",
53+
"**/User/profiles/*/snippets/*.json",
54+
"**/snippets*.json",
55+
"**/.cursor/**/*.mdc",
56+
"**/.github/agents/*.md",
57+
"tsconfig.*.json",
58+
"jsconfig.*.json",
59+
"tsconfig-*.json",
60+
"jsconfig-*.json",
61+
"compose.yml",
62+
"compose.yaml",
63+
"compose.*.yml",
64+
"compose.*.yaml",
65+
"*docker*compose*.yml",
66+
"*docker*compose*.yaml",
67+
"**/templates/**/*.html",
68+
"**/templates/**/*",
69+
"**/test/integration/**/*.rb",
70+
"**/controls/*.rb",
71+
"**/recipes/*.yml",
72+
"**/recipes/*.yaml",
73+
"*suite*.rc",
74+
"suite*.rc.*",
75+
"flow.rc",
76+
"flow-tests.rc",
77+
"@vcode-tm-log-*-*-*-*-*.txt"
78+
],
1579
"firstLine": "{(\"scopeName\"|\"(information_for_contributors|fileTypes)\":\\[)",
1680
"configuration": "./language-configuration.json",
1781
"icon": {
@@ -347,5 +411,13 @@
347411
"when": "workspacePlatform != webworker"
348412
}
349413
]
414+
},
415+
"workspaces": [
416+
"workspace/**"
417+
],
418+
"workspaces": {
419+
"packages": [
420+
"workspace/**"
421+
]
350422
}
351423
}

0 commit comments

Comments
 (0)