mirror of
https://git.tuxpa.in/a/code-server.git
synced 2024-12-27 04:35:25 +00:00
Bundle grammars (#563)
This commit is contained in:
parent
d073622629
commit
e61ea796c6
@ -2,6 +2,17 @@ import * as vscodeTextmate from "../../../../lib/vscode/node_modules/vscode-text
|
||||
|
||||
const target = vscodeTextmate as typeof vscodeTextmate;
|
||||
|
||||
const ctx = (require as any).context("../../../../lib/extensions", true, /.*\.tmLanguage.json$/);
|
||||
// Maps grammar scope to loaded grammar
|
||||
const scopeToGrammar = {} as any;
|
||||
|
||||
ctx.keys().forEach((key: string) => {
|
||||
const value = ctx(key);
|
||||
if (value.scopeName) {
|
||||
scopeToGrammar[value.scopeName] = value;
|
||||
}
|
||||
});
|
||||
|
||||
target.Registry = class Registry extends vscodeTextmate.Registry {
|
||||
public constructor(opts: vscodeTextmate.RegistryOptions) {
|
||||
super({
|
||||
@ -21,6 +32,13 @@ target.Registry = class Registry extends vscodeTextmate.Registry {
|
||||
}).catch(reason => rej(reason));
|
||||
});
|
||||
},
|
||||
loadGrammar: async (scopeName: string) => {
|
||||
if (scopeToGrammar[scopeName]) {
|
||||
return scopeToGrammar[scopeName];
|
||||
}
|
||||
|
||||
return opts.loadGrammar(scopeName);
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user