Files
plainleaf/plugs/editor/command.ts
T
Zef HemelandGitHub 6b69449d05 More JSR (#1027)
* Move all syscalls to JSR-style package naming
* Eliminating some prefixes in import maps
2024-08-06 20:11:38 +02:00

20 lines
538 B
TypeScript

import { system } from "@silverbulletmd/silverbullet/syscalls";
import type { CompleteEvent } from "../../plug-api/types.ts";
export async function commandComplete(completeEvent: CompleteEvent) {
const match = /\{\[([^\]\[]*)$/.exec(completeEvent.linePrefix);
if (!match) {
return null;
}
const allCommands = await system.listCommands();
return {
from: completeEvent.pos - match[1].length,
options: Object.keys(allCommands).map((commandName) => ({
label: commandName,
type: "command",
})),
};
}