| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .. | ||
| src | ||
| tests | ||
| build.cjs | ||
| CHANGELOG.md | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
@gram-lang/language-server
Part of the Gram monorepo · Documentation
Language Server Protocol (LSP) implementation for the Gram recipe DSL. Provides diagnostics, semantic tokens, autocomplete, hover information, refactoring, formatting, and live view updates for any LSP-compatible editor.
Installation
npm install @gram-lang/language-server
# or
bun add @gram-lang/language-server
Usage
Intended for editor extensions and IDEs supporting the Language Server Protocol (VS Code, VSCodium, Neovim, Helix, Zed, Emacs, Monaco Editor). See the editors guide for editor-specific setup.
From a VS Code / Node.js extension client:
import { LanguageClient, TransportKind } from 'vscode-languageclient/node';
const serverModule = require.resolve('@gram-lang/language-server');
const client = new LanguageClient(
'gramLanguageServer',
'Gram Language Server',
{
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc }
},
{
documentSelector: [{ scheme: 'file', language: 'gram' }]
}
);
client.start();
Capabilities
- Diagnostics: real-time syntax and semantic validation (compound quantities, unit ratios, durations, target states, missing or unused references, circular
@useimports). - Semantic tokens: highlighting for ingredients, quantities, cookware, timers, temperatures, and target states (
={...}). - Hover: nutritional info, scaled quantities, duration breakdowns, and unit-ratio details.
- Completion: suggestions for units (including ratio denominators), ingredients from the local YAML database, cookware, and
@useimport paths. - Navigation and refactoring: go to definition, find all references, rename symbol (
F2across references,%, and unit ratios), document symbols, and folding ranges. - Code actions, inlay hints and CodeLens: quick fixes, volume-to-mass conversions, total-time inlay hints, and preview CodeLens.
- Document formatting: canonical
.gramformatting via@gram-lang/format. - Views protocol: renders only outputs currently open in the client (
gram/setOpenViews) and replies withgram/viewUpdated(recipe and run sheet as HTML, AST and compiled JSON as text or interactive tree). On error, open views pause under a localized banner instead of being replaced. Available outputs are advertised incapabilities.experimental.gramViews. Legacygram/previewUpdatedandgram/ganttUpdatednotifications remain deprecated until 2.0.0. - Sessions:
gram/setSessionstores transient per-sitting state (serving time, scale, in-stock imports, baker's reference) without modifying the file;gram/sessionChoiceslists available controls andgram/serveTimesproposes valid serving times against the project'smealTimesandavailability. - Settings and project config:
gram.*client settings and.gram/config.yamlchanges (timezone,availability,paths) apply live to all open recipes.
License
Licensed under the GPL-3.0 license.