1
0
silverbullet/plugs/core/command.ts

19 lines
493 B
TypeScript
Raw Normal View History

import { matchBefore } from "../../syscall/silverbullet-syscall/editor.ts";
import { listCommands } from "../../syscall/silverbullet-syscall/system.ts";
2022-09-06 12:36:06 +00:00
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",
})),
};
}