Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/packages/vscode/src/fill/vscodeTextmate.ts

37 lines
1.1 KiB
TypeScript
Raw Normal View History

import * as vscodeTextmate from "../../../../lib/vscode/node_modules/vscode-textmate";
const target = vscodeTextmate as typeof vscodeTextmate;
target.Registry = class Registry extends vscodeTextmate.Registry {
public constructor(opts: vscodeTextmate.RegistryOptions) {
super({
...opts,
getOnigLib: (): Promise<vscodeTextmate.IOnigLib> => {
return new Promise<vscodeTextmate.IOnigLib>((res, rej) => {
2019-01-30 22:40:01 +01:00
const onigasm = require("onigasm");
const wasmUrl = require("!!file-loader!onigasm/lib/onigasm.wasm");
return fetch(wasmUrl).then(resp => resp.arrayBuffer()).then(buffer => {
return onigasm.loadWASM(buffer);
}).then(() => {
res({
createOnigScanner: function (patterns) { return new onigasm.OnigScanner(patterns); },
2019-01-30 22:40:01 +01:00
createOnigString: function (s) { return new onigasm.OnigString(s); },
});
}).catch(reason => rej(reason));
});
},
});
}
2019-01-30 22:40:01 +01:00
};
enum StandardTokenType {
Other = 0,
2019-01-30 22:40:01 +01:00
Comment = 1,
String = 2,
RegEx = 4,
}
2019-01-30 22:40:01 +01:00
// tslint:disable-next-line no-any to override const
(target as any).StandardTokenType = StandardTokenType;