Files
plainleaf/client/cm_plugins/lint.ts
T
Zef HemelandGitHub a524c64884 Go backend (#1555)
* Replaces old Deno server with a Go implementation
* Restructured the code base accordingly
2025-09-19 13:23:20 +02:00

20 lines
682 B
TypeScript

import { type Diagnostic, linter } from "@codemirror/lint";
import type { Client } from "../client.ts";
import { parse } from "../markdown_parser/parse_tree.ts";
import { extendedMarkdownLanguage } from "../markdown_parser/parser.ts";
import type { LintEvent } from "@silverbulletmd/silverbullet/type/client";
export function plugLinter(client: Client) {
return linter(async (view): Promise<Diagnostic[]> => {
const tree = parse(
extendedMarkdownLanguage,
view.state.sliceDoc(),
);
const results = (await client.dispatchAppEvent("editor:lint", {
name: client.currentName(),
tree: tree,
} as LintEvent)).flat();
return results;
});
}