Skip to content

Commit e61ea79

Browse files
kylecarbscode-asher
authored andcommitted
Bundle grammars (coder#563)
1 parent d073622 commit e61ea79

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/vscode/src/fill/vscodeTextmate.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ import * as vscodeTextmate from "../../../../lib/vscode/node_modules/vscode-text
22

33
const target = vscodeTextmate as typeof vscodeTextmate;
44

5+
const ctx = (require as any).context("../../../../lib/extensions", true, /.*\.tmLanguage.json$/);
6+
// Maps grammar scope to loaded grammar
7+
const scopeToGrammar = {} as any;
8+
9+
ctx.keys().forEach((key: string) => {
10+
const value = ctx(key);
11+
if (value.scopeName) {
12+
scopeToGrammar[value.scopeName] = value;
13+
}
14+
});
15+
516
target.Registry = class Registry extends vscodeTextmate.Registry {
617
public constructor(opts: vscodeTextmate.RegistryOptions) {
718
super({
@@ -21,6 +32,13 @@ target.Registry = class Registry extends vscodeTextmate.Registry {
2132
}).catch(reason => rej(reason));
2233
});
2334
},
35+
loadGrammar: async (scopeName: string) => {
36+
if (scopeToGrammar[scopeName]) {
37+
return scopeToGrammar[scopeName];
38+
}
39+
40+
return opts.loadGrammar(scopeName);
41+
},
2442
});
2543
}
2644
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy