Refactor all the things

This commit is contained in:
Zef Hemel
2023-08-28 17:12:15 +02:00
parent 54d2deea15
commit 5ff1a8bae3
87 changed files with 930 additions and 896 deletions
+34
View File
@@ -0,0 +1,34 @@
import { readCodeBlockPage } from "$sb/lib/yaml_page.ts";
import { editor, store } from "$sb/syscalls.ts";
export async function toggleVimMode() {
let vimMode = await store.get("vimMode");
vimMode = !vimMode;
await editor.setUiOption("vimMode", vimMode);
await store.set("vimMode", vimMode);
}
export async function loadVimRc() {
const vimMode = await editor.getUiOption("vimMode");
if (!vimMode) {
console.log("Not in vim mode");
return;
}
try {
const vimRc = await readCodeBlockPage("VIMRC");
if (vimRc) {
console.log("Now running vim ex commands from VIMRC");
const lines = vimRc.split("\n");
for (const line of lines) {
try {
console.log("Running vim ex command", line);
await editor.vimEx(line);
} catch (e: any) {
await editor.flashNotification(e.message, "error");
}
}
}
} catch (e: any) {
// No VIMRC page found
}
}