Cooklang Language Server
A Language Server Protocol (LSP) implementation for Cooklang, the markup language for recipes.
This language server provides rich editor support for .cook files, including syntax highlighting, auto-completion, and real-time error checking. It works with any LSP-compatible editor like VS Code, Neovim, Emacs, and Helix.
Features
- 🔍 Diagnostics - Real-time syntax checking and validation with helpful error messages
- ✨ Auto-completion - Smart suggestions for ingredients (
@), cookware (#), timers (~), and units (%) - 🎨 Syntax Highlighting - Semantic token-based colorization for all Cooklang elements
- 📖 Hover Information - View ingredient details, quantities, and notes on hover
- 📑 Document Outline - Navigate recipe structure with sections, ingredients, and cookware
Installation
The Cooklang Language Server is available through the cook command-line tool.
Using with cook
The language server can be invoked via:
This starts the LSP server and communicates over stdin/stdout, which is the standard LSP transport mechanism.
Editor Setup
Once you have cook installed, configure your editor to use it as the language server for .cook files.
VS Code
Install the Cooklang extension from the marketplace or GitHub.
Neovim
Using nvim-lspconfig:
require..
Helix
Add to your ~/.config/helix/languages.toml:
[[]]
= "cooklang"
= "source.cook"
= ["cook"]
= ["cooklang-lsp"]
[]
= "cook"
= ["lsp"]
Other Editors
Any LSP-compatible editor can use this language server. Configure it to run cook lsp for .cook files.
Supported Features
Diagnostics
Get real-time feedback on syntax errors and warnings:
- Missing closing braces in ingredients, cookware, or timers
- Invalid quantity formats
- Malformed metadata
- Extension-specific validation
Auto-completion
Context-aware suggestions triggered by:
@- Suggests ingredients from the current recipe and workspace#- Suggests cookware (both used in recipe and common items like "pot", "pan", "oven")~- Suggests time units (seconds, minutes, hours)%- Suggests measurement units (g, kg, ml, cups, tbsp, etc.)
Syntax Highlighting
Semantic token-based highlighting for:
- Ingredients (
@potato{2}) - Cookware (
#pot) - Timers (
~{25%minutes}) - Quantities and units
- Comments (
--and[- -]) - Metadata keys and values
- Section headers (
== Preparation ==)
Additional Features
- Hover Information - View ingredient quantities, notes, and modifiers
- Document Symbols - Navigate recipe structure via outline view
- Go to Definition - Jump to first use of ingredients
- Find References - Find all uses of an ingredient
Technology
This language server is built with:
- Rust - For performance and reliability
- tower-lsp - LSP framework
- cooklang-rs - Official Cooklang parser
Development
This repository contains the core LSP implementation. For building from source or contributing:
# Build the project
# Run tests
# The binary will be at target/release/cooklang-lsp
License
Licensed under the MIT License.