improve monokai by making the language a superset of javascript

This commit is contained in:
Olivier Gagnon 2021-10-15 18:25:22 -04:00
parent b5a8ed1d9d
commit 80d197652d
5 changed files with 23 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -55,7 +55,7 @@ export function SetupTextEditor(): void {
symbols = populate(ns);
const exclude = ["heart", "break", "exploit", "bypass", "corporation"];
symbols = symbols.filter((symbol: string) => !exclude.includes(symbol));
symbols = symbols.filter((symbol: string) => !exclude.includes(symbol)).sort();
}
interface IProps {
@ -311,6 +311,16 @@ export function Root(props: IProps): React.ReactElement {
return { suggestions: suggestions };
},
});
(async function () {
const l = await monaco.languages
.getLanguages()
.find((l: any) => l.id === "javascript")
.loader();
l.language.tokenizer.root.unshift(["ns", { token: "ns" }]);
for (const symbol of symbols) l.language.tokenizer.root.unshift(["\\." + symbol, { token: "netscriptfunction" }]);
console.log(l);
})();
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, "netscript.d.ts");
monaco.languages.typescript.typescriptDefaults.addExtraLib(libSource, "netscript.d.ts");
loadThemes(monaco);

@ -31,7 +31,14 @@ export async function loadThemes(monaco: { editor: any }): Promise<void> {
token: "storage.type.function.js",
foreground: "ae81ff",
},
{
token: "ns",
foreground: "97d92b",
},
{
token: "netscriptfunction",
foreground: "53d3e4",
},
// {
// foreground: "ae81ff",
// token: "entity.name.function",

@ -239,7 +239,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
SuppressMessages: defaultSettings.SuppressMessages,
SuppressTravelConfirmation: defaultSettings.SuppressTravelConfirmation,
SuppressBladeburnerPopup: defaultSettings.SuppressBladeburnerPopup,
MonacoTheme: "vs-dark",
MonacoTheme: "monokai",
MonacoInsertSpaces: false,
MonacoFontSize: 20,