Skip to content

Language service

@ministryplace/flowmark-language-service is the host-neutral source of Flowmark editor semantics. Monaco hosts call it directly; LSP clients launch flowmark lsp --stdio.

example.ts
import { FlowmarkLanguageService } from "@ministryplace/flowmark-language-service";
const service = new FlowmarkLanguageService();
const uri = "file:///architecture.flowmark";
service.updateDocument(uri, source, 1);
const diagnostics = service.diagnostics(uri);
const completions = service.complete(uri, { line: 4, column: 12 });

Document versions are monotonic: an update older than the active snapshot is ignored. Hosts close documents explicitly with closeDocument. Positions and ranges in this package are one-based and include source offsets where known; thin adapters convert them to editor-native coordinates.

The service provides diagnostics, completion, hover, definition, references, rename, document symbols, folding ranges, semantic tokens, formatting edits, and code actions. Completion catalogs cover built-in kinds, identifiers, properties, shapes, styles, icons, theme tokens, values, and table columns. Incomplete source still produces a current diagnostic snapshot from the recovering Flowmark parser.

Extensions can register semantic kinds and properties without replacing the parser or service:

example.ts
const unregister = service.registerExtension({
protocolVersion: 1,
id: "acme.platform",
kinds: {
queueWorker: { description: "Worker that consumes the platform queue", shape: "hexagon" },
},
properties: [{ name: "owner", description: "Owning team" }],
});

The explicit protocolVersion makes incompatible extension changes detectable. Registration is local to a service instance and returns an unregister function; it does not mutate Flowmark’s global compiler registries.