1
0
silverbullet/plugs/core/command.ts
Zef Hemel 561aa6891f
Migrate to Deno (#86)
Big bang migration to Deno 🤯
2022-10-10 14:50:21 +02:00

19 lines
493 B
TypeScript

import { matchBefore } from "../../syscall/silverbullet-syscall/editor.ts";
import { listCommands } from "../../syscall/silverbullet-syscall/system.ts";
export async function commandComplete() {
let prefix = await matchBefore("\\{\\[[^\\]]*");
if (!prefix) {
return null;
}
let allCommands = await listCommands();
return {
from: prefix.from + 2,
options: Object.keys(allCommands).map((commandName) => ({
label: commandName,
type: "command",
})),
};
}