gram/packages/language-server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
abiwab 7d67ccadaf
All checks were successful
CI / Build & Test (pull_request) Successful in 9m18s
chore: release v1.6.0
2026-12-01 14:38:56 +01:00
..
src fix(language-server): confine @use path completion to the project 2026-11-29 19:54:04 +01:00
tests Merge pull request 'fix: pre-release 1.6 code polish (L1, L3, N1, N2, N7)' (#321) from fix/pre-release-1.6-polish into dev/1.6 2026-11-29 21:09:43 +01:00
build.cjs feat(language-server): answer --version and --help 2026-11-24 16:16:27 +01:00
CHANGELOG.md chore: release v1.6.0 2026-12-01 14:38:56 +01:00
package.json chore: release v1.6.0 2026-12-01 14:38:56 +01:00
README.md docs: rewrite root and package READMEs for v1.6 2026-11-29 22:35:50 +01:00
tsconfig.json chore: bump all dependencies and migrate to typescript 7 dual setup 2026-07-13 13:17:12 +02:00

@gram-lang/language-server

npm License: GPL v3

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 @use imports).
  • 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 @use import paths.
  • Navigation and refactoring: go to definition, find all references, rename symbol (F2 across 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 .gram formatting via @gram-lang/format.
  • Views protocol: renders only outputs currently open in the client (gram/setOpenViews) and replies with gram/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 in capabilities.experimental.gramViews. Legacy gram/previewUpdated and gram/ganttUpdated notifications remain deprecated until 2.0.0.
  • Sessions: gram/setSession stores transient per-sitting state (serving time, scale, in-stock imports, baker's reference) without modifying the file; gram/sessionChoices lists available controls and gram/serveTimes proposes valid serving times against the project's mealTimes and availability.
  • Settings and project config: gram.* client settings and .gram/config.yaml changes (timezone, availability, paths) apply live to all open recipes.

License

Licensed under the GPL-3.0 license.