Skip to content

Commit

Permalink
fix: use different scope name for angular langs
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 8, 2024
1 parent 4cee1cb commit b1804bd
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 55 deletions.
32 changes: 16 additions & 16 deletions packages/tm-grammars/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/tm-grammars/grammars/angular-html.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
]
}
],
"scopeName": "text.html.derivative"
"scopeName": "text.html.derivative.ng"
}
2 changes: 1 addition & 1 deletion packages/tm-grammars/grammars/angular-inline-style.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"injectTo": [
"source.ts"
"source.ts.ng"
],
"injectionSelector": "L:source.ts#meta.decorator.ts -comment",
"name": "angular-inline-style",
Expand Down
4 changes: 2 additions & 2 deletions packages/tm-grammars/grammars/angular-inline-template.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"injectTo": [
"source.ts"
"source.ts.ng"
],
"injectionSelector": "L:meta.decorator.ts -comment -text.html",
"name": "angular-inline-template",
Expand Down Expand Up @@ -46,7 +46,7 @@
},
"patterns": [
{
"include": "text.html.derivative"
"include": "text.html.derivative.ng"
},
{
"include": "template.ng"
Expand Down
5 changes: 3 additions & 2 deletions packages/tm-grammars/grammars/angular-template-blocks.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"injectTo": [
"text.html.derivative",
"source.ts"
"text.html.derivative.ng",
"source.ts.ng"
],
"injectionSelector": "L:text.html -comment -expression.ng -meta.tag -source.css -source.js",
"name": "angular-template-blocks",
Expand Down Expand Up @@ -52,7 +53,7 @@
},
"patterns": [
{
"include": "text.html.derivative"
"include": "text.html.derivative.ng"
},
{
"include": "template.ng"
Expand Down
3 changes: 2 additions & 1 deletion packages/tm-grammars/grammars/angular-template.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"injectTo": [
"text.html.derivative",
"source.ts"
"text.html.derivative.ng",
"source.ts.ng"
],
"injectionSelector": "L:text.html -comment",
"name": "angular-template",
Expand Down
2 changes: 1 addition & 1 deletion packages/tm-grammars/grammars/angular-ts.json
Original file line number Diff line number Diff line change
Expand Up @@ -5731,5 +5731,5 @@
]
}
},
"scopeName": "source.ts"
"scopeName": "source.ts.ng"
}
44 changes: 44 additions & 0 deletions packages/tm-grammars/grammars/html-derivative.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"displayName": "HTML (Derivative)",
"injections": {
"R:text.html - (comment.block, text.html meta.embedded, meta.tag.*.*.html, meta.tag.*.*.*.html, meta.tag.*.*.*.*.html)": {
"comment": "Uses R: to ensure this matches after any other injections.",
"patterns": [
{
"match": "<",
"name": "invalid.illegal.bad-angle-bracket.html"
}
]
}
},
"name": "html-derivative",
"patterns": [
{
"include": "text.html.basic#core-minus-invalid"
},
{
"begin": "(</?)(\\w[^\\s>]*)(?<!/)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.begin.html"
},
"2": {
"name": "entity.name.tag.html"
}
},
"end": "((?: ?/)?>)",
"endCaptures": {
"1": {
"name": "punctuation.definition.tag.end.html"
}
},
"name": "meta.tag.other.unrecognized.html.derivative",
"patterns": [
{
"include": "text.html.basic#attribute"
}
]
}
],
"scopeName": "text.html.derivative"
}
49 changes: 23 additions & 26 deletions packages/tm-grammars/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ export const grammars = [
source: 'https://github.com/AdaCore/ada_language_server/blob/75c0d0c22b3f3dbf559946331c7aca6fc5b84065/integration/vscode/ada/advanced/ada.tmLanguage.json',
},
{
byteSize: 769,
byteSize: 772,
categories: [
'web',
'markup',
],
displayName: 'Angular HTML',
embedded: [
Expand All @@ -55,12 +54,12 @@ export const grammars = [
license: 'MIT',
licenseUrl: 'https://raw.githubusercontent.com/onivim/vscode-exthost/master/LICENSE.txt',
name: 'angular-html',
scopeName: 'text.html.derivative',
scopeName: 'text.html.derivative.ng',
sha: 'cfc2a2212de9ea10943af58ebd1817a5ad196463',
source: 'https://github.com/onivim/vscode-exthost/blob/cfc2a2212de9ea10943af58ebd1817a5ad196463/extensions/html/syntaxes/html-derivative.tmLanguage.json',
},
{
byteSize: 193129,
byteSize: 193132,
categories: [
'web',
],
Expand All @@ -76,7 +75,7 @@ export const grammars = [
license: 'MIT',
licenseUrl: 'https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt',
name: 'angular-ts',
scopeName: 'source.ts',
scopeName: 'source.ts.ng',
sha: 'c778cc6117ba3b243a8e2321b4cf33062546e312',
source: 'https://github.com/microsoft/vscode/blob/c778cc6117ba3b243a8e2321b4cf33062546e312/extensions/typescript-basics/syntaxes/TypeScript.tmLanguage.json',
},
Expand Down Expand Up @@ -161,7 +160,7 @@ export const grammars = [
embedded: [
'json',
'javascript',
'angular-ts',
'typescript',
'stylus',
'sass',
'css',
Expand Down Expand Up @@ -795,7 +794,7 @@ export const grammars = [
byteSize: 1299,
displayName: 'Glimmer TS',
embedded: [
'angular-ts',
'typescript',
'handlebars',
],
lastUpdate: '2023-07-03T16:07:58Z',
Expand Down Expand Up @@ -854,7 +853,7 @@ export const grammars = [
displayName: 'GraphQL',
embedded: [
'javascript',
'angular-ts',
'typescript',
'jsx',
'tsx',
],
Expand Down Expand Up @@ -1047,7 +1046,7 @@ export const grammars = [
],
displayName: 'Imba',
embedded: [
'angular-ts',
'typescript',
],
lastUpdate: '2023-12-15T08:11:58Z',
license: 'MIT',
Expand Down Expand Up @@ -1310,7 +1309,7 @@ export const grammars = [
'julia',
'ruby',
'javascript',
'angular-ts',
'typescript',
'python',
'yaml',
'rust',
Expand Down Expand Up @@ -1465,7 +1464,7 @@ export const grammars = [
'rust',
'scala',
'shellscript',
'angular-ts',
'typescript',
'tsx',
'csharp',
'fsharp',
Expand All @@ -1475,7 +1474,6 @@ export const grammars = [
'elixir',
'latex',
'bibtex',
'angular-html',
],
lastUpdate: '2023-12-13T12:08:01Z',
license: 'MIT',
Expand Down Expand Up @@ -1525,7 +1523,6 @@ export const grammars = [
embedded: [
'markdown',
'yaml',
'angular-html',
],
lastUpdate: '2023-09-01T11:16:46Z',
license: 'MIT',
Expand Down Expand Up @@ -1584,7 +1581,7 @@ export const grammars = [
'sql',
'xml',
'swift',
'angular-ts',
'typescript',
],
lastUpdate: '2023-10-26T10:56:19Z',
license: 'MIT',
Expand Down Expand Up @@ -2046,7 +2043,6 @@ export const grammars = [
],
displayName: 'reStructuredText',
embedded: [
'angular-html',
'cpp',
'python',
'javascript',
Expand Down Expand Up @@ -2344,7 +2340,7 @@ export const grammars = [
displayName: 'Svelte',
embedded: [
'javascript',
'angular-ts',
'typescript',
'coffee',
'stylus',
'sass',
Expand Down Expand Up @@ -2580,7 +2576,7 @@ export const grammars = [
'scss',
'less',
'javascript',
'angular-ts',
'typescript',
'jsx',
'tsx',
'json',
Expand All @@ -2589,7 +2585,6 @@ export const grammars = [
'yaml',
'toml',
'graphql',
'angular-html',
'markdown-vue',
'vue-directives',
'vue-interpolations',
Expand Down Expand Up @@ -2786,15 +2781,15 @@ export const injections = [
source: 'https://github.com/angular/vscode-ng-language-service/blob/d7dab52644375e64af3deaeac045cc75f5954414/syntaxes/expression.json',
},
{
byteSize: 1195,
byteSize: 1198,
embedded: [
'scss',
],
embeddedIn: [
'angular-ts',
],
injectTo: [
'source.ts',
'source.ts.ng',
],
lastUpdate: '2023-11-03T16:23:10Z',
license: 'MIT',
Expand All @@ -2805,7 +2800,7 @@ export const injections = [
source: 'https://github.com/angular/vscode-ng-language-service/blob/f0422f5f571f79a904510944452f06fb36beff22/syntaxes/inline-styles.json',
},
{
byteSize: 950,
byteSize: 956,
embedded: [
'angular-html',
'angular-template',
Expand All @@ -2814,7 +2809,7 @@ export const injections = [
'angular-ts',
],
injectTo: [
'source.ts',
'source.ts.ng',
],
lastUpdate: '2020-07-06T21:15:10Z',
license: 'MIT',
Expand All @@ -2825,7 +2820,7 @@ export const injections = [
source: 'https://github.com/angular/vscode-ng-language-service/blob/c3f3172a70b1a2bfdca3bdee85df9271cb0895cf/syntaxes/inline-template.json',
},
{
byteSize: 3164,
byteSize: 3193,
embedded: [
'angular-expression',
],
Expand All @@ -2835,7 +2830,8 @@ export const injections = [
],
injectTo: [
'text.html.derivative',
'source.ts',
'text.html.derivative.ng',
'source.ts.ng',
],
lastUpdate: '2022-04-01T23:00:39Z',
license: 'MIT',
Expand All @@ -2846,7 +2842,7 @@ export const injections = [
source: 'https://github.com/angular/vscode-ng-language-service/blob/38481421878d59dda0a69e508e97265c8e173fcd/syntaxes/template.json',
},
{
byteSize: 1119,
byteSize: 1151,
embedded: [
'angular-expression',
'angular-template',
Expand All @@ -2857,7 +2853,8 @@ export const injections = [
],
injectTo: [
'text.html.derivative',
'source.ts',
'text.html.derivative.ng',
'source.ts.ng',
],
lastUpdate: '2023-12-05T18:19:48Z',
license: 'MIT',
Expand Down
1 change: 1 addition & 0 deletions scripts/grammars/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ async function fetchGrammar(source: GrammarSource) {
// Apply custom patching function
parsed = source.patch?.(parsed) || parsed
// Update info
parsed.scopeName = info.scopeName || parsed.scopeName
info.scopeName = parsed.scopeName
info.displayName ||= parsed.name
parsed.name = info.name
Expand Down
1 change: 1 addition & 0 deletions scripts/grammars/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface GrammarSource {
categories?: GrammarCategory[]
source: string
aliases?: string[]
scopeName?: string

/**
* Download from marketplace.
Expand Down
Loading

0 comments on commit b1804bd

Please sign in to comment.