Merge pull request #1515 from danielyxie/dev

improve monokai by making the language a superset of javascript
This commit is contained in:
hydroflame 2021-10-15 18:25:37 -04:00 committed by GitHub
commit d4086bf467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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); symbols = populate(ns);
const exclude = ["heart", "break", "exploit", "bypass", "corporation"]; 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 { interface IProps {
@ -311,6 +311,16 @@ export function Root(props: IProps): React.ReactElement {
return { suggestions: suggestions }; 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.javascriptDefaults.addExtraLib(libSource, "netscript.d.ts");
monaco.languages.typescript.typescriptDefaults.addExtraLib(libSource, "netscript.d.ts"); monaco.languages.typescript.typescriptDefaults.addExtraLib(libSource, "netscript.d.ts");
loadThemes(monaco); loadThemes(monaco);

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

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