Editor setup
lttr has a language server. Your editor runs it and talks to it over stdin and stdout, and you get the same checks as lttr lint and the studio, as you type, before you save:
- Problems. Every error and warning, at its line and column. That includes a kit's own problems, shown in the kit file they are in, such as
kit.yamlor a component'shtml.tmpl. - Quick fixes. A problem with a "did you mean" suggestion offers a fix,
Replace with "otp_code", which edits the misspelt name in place. - Completion. In a template: component names after
::; attribute names, and binding names as:invoice=""; enum values; and data paths, segment by segment, in a merge tag ({{invoice.) or a binding's value (:invoice="invoice.). In a kit template: token and var names, and.Attrsfields. - Hover. On
::name, the component: its attributes, bindings, content rules and children. On a data path, in a merge tag or a binding's value, the path and its type, such asinvoice.total→tutorial.Money. - Go to definition. From
::nameto the component'scomponent.yamlandhtml.tmpl. Fromtoken "…"orvar "…"in a kit template to its key inkit.yaml. A kit that is embedded in a binary, not on disk, has nowhere to go.
The server rebuilds 150 ms after you stop typing. A template that stops compiling keeps its last good render in the studio, and its problems show at once.
Choose the server
There are two servers, because the lttr binary cannot know an app's own Go types. Loading such a kit with stand-in types would report a false error on every binding, so a typed app runs the server from its own program instead:
| Your templates | Run | Problems | Completion, hover, definition |
|---|---|---|---|
quiet, plain, or a kit directory with no Go types | lttr lsp | Exact | Yes |
| An app whose kit binds its own Go types | emaildev lsp: your studio program's lsp subcommand | Exact, with the real types | Yes, from the real types |
That app's templates, opened under lttr lsp | — | None | Yes, from .lttr/schema.json |
lttr lsp
go install github.com/sulv-io/lttr/cmd/lttr@latest
Your editor starts lttr lsp; you don't run it yourself. What a file is checked against depends on -kit:
- With
-kit(quiet,plainor a kit directory, with-dirand-goldenas forserve), every file belongs to that kit. A Markdown file outside its samples and outside the kit directory is compiled against it as untyped data..lttr/schema.jsonis not read: a kit that binds Go types, named with-kit, fails to load and shows the hint below. - Without
-kit, each file finds its own kit:- a file in a kit directory (the nearest one up holding
kit.yaml) belongs to that kit, and so does any other Markdown file inside it; - a file that a
.lttr/schema.jsondescribes, in its kit or template directory, gets completion, hover and definition from it, and no problems; - any other file belongs to
quiet, with-dirand-golden. Only Quiet's own templates are checked there: a README or a changelog gets no lttr problems.
- a file in a kit directory (the nearest one up holding
Relative -kit, -dir and -golden paths are relative to the directory the editor starts the server in, so give absolute paths when you use them.
A kit that binds Go types fails to load under lttr lsp when no .lttr/schema.json describes it, or when you name it with -kit. Its problem, on kit.yaml, says what to do:
types: "Invoice" is not registered; this kit binds Go types: run your app's studio program with the lsp subcommand (see Editor setup)
emaildev lsp
An app that runs the studio from Go, with studio.Options, has the language server too, as its lsp subcommand. Every file builds with the program's kit, Go types, loader and samples, unsaved buffers included, so its problems and completions are exact:
$ go run ./examples/tutorial/cmd/emaildev lsp -h
usage: emaildev lsp [-studio host:port] [-golden dir] [-editor name] [-send-to addr,…]
Runs the lttr language server for an editor, on stdin and stdout, until
the editor tells it to exit. Every file it opens builds with this
program's kit, Go types and samples, unsaved buffers included, so its
problems and completions are exact. A change to Go data or Go types
needs a restart.
With -studio, it also serves the studio on host:port, on the same
engine, so the preview follows the buffers as you type. If the studio
cannot start, the editor shows why and the language server runs on.
Stdout carries the protocol alone; logs, and the studio's serving line,
go to stderr.
flags:
-editor editor
editor that the studio's problem links open: vscode, cursor, zed, idea or none (default "vscode")
-golden dir
golden dir (<Name>.html and <Name>.txt) for the studio's golden status; empty for none (default "examples/tutorial/testdata")
-send-to addresses
addresses the studio's test sends may go to, comma-separated (else LTTR_STUDIO_SEND_TO); SMTP from LTTR_SMTP_ADDR, _USER, _PASS and _FROM
-studio host:port
also serve the studio on host:port, following the editor's buffers
KitDir and TemplateDir are relative to the working directory, so the editor must start it in the module root, as you run the studio. After a change to Go code, restart the language server from your editor.
Describe a typed app in schema.json
.lttr/schema.json describes a typed app's kit and data for editors that run plain lttr lsp. It holds:
version(1) andgenerator, the lttr version that wrote it;kit: its name, its directory, its default component, and every component with its attributes, bindings and content rules, the tokens, the vars, the span classes and the frontmatter keys;templateDir, and for each template its file, its name, the Go type of its data, and every merge-tag path with its type.
Paths in it are slash-separated and relative to the module root. Your studio program writes it with its schema subcommand:
$ go run ./examples/tutorial/cmd/emaildev schema -h
usage: emaildev schema [-o file]
Writes .lttr/schema.json at the module root (the nearest directory up from here
holding go.mod): the kit's components, tokens and vars, and the data
paths of each template, for editors. Run it again after changing the
kit or the Go data types.
flags:
-o file
write to file instead of <module root>/.lttr/schema.json
The module root is the nearest directory up from the working directory that holds go.mod, else the working directory. Commit the file, and write it again after a change to the kit or to the Go data types. Without -kit, lttr lsp finds the nearest .lttr/schema.json that describes the file and reads it again whenever it changes, so there is nothing to restart. It gives completion, hover and definition to the files in the kit directory and the template directory the file names, and never publishes problems for them: only emaildev lsp knows the real types.
A file of another version is passed over, and the language server's log says why: schema.json version 2; regenerate it with your studio program's schema subcommand.
In the lttr repository, make schema writes the tutorial's .lttr/schema.json, and TestSchemaFresh in examples/tutorial fails when the committed file is out of date. It ignores generator, so a release that bumps the version doesn't make the file stale.
Preview as you type
-studio host:port serves the studio from the language server itself, on the same engine, so the preview follows the text in your editor before you save it:
lttr lsp -studio localhost:7070
lttr lsp -kit ./kit -studio localhost:7070
go run ./examples/tutorial/cmd/emaildev lsp -studio localhost:7070
Put the flag in your editor's command, then open the address in a browser. The studio's serving line, lttr studio: serving kit (2 samples) on http://localhost:7070, goes to the server's stderr, which most editors keep in a log.
- Which kit it serves. With
-kit, that kit. Without it, the kit directory at or above the working directory, elsequiet.emaildev lsp -studioserves the app's sample set. - Unsaved text. While the page shows a render of an unsaved buffer, the pill reads
Live · unsaved buffer, and a render that differs from its golden saysΔ differs from golden · unsaved. Save, and the pill returns toLive · watching …. Close the file without saving, and the preview returns to the text on disk. - New files. A file that exists only in your editor, never saved, can be read by the kit, but it isn't listed as a new sample until you save it.
- Writes use the files on disk. Accept is off while the render uses unsaved text, and the Diff tab says
This render uses unsaved editor text; save it first.Save to samples.yaml refuses whilesamples.yamlitself has unsaved changes in your editor:samples.yaml has unsaved changes in your editor; save it first. A golden, or a saved data edit, never holds text you haven't saved. - A typed kit.
lttr lsp -studiostarted inside a kit directory that.lttr/schema.jsondescribes serves no studio. The editor showslttr studio: this kit binds Go types: run your app's studio program with lsp -studio, and the language server runs on. - A busy port. If the studio cannot start, the editor shows why, such as
lttr studio: listen tcp 127.0.0.1:7070: bind: address already in use, and the language server runs on. -editorand-send-towork as forserve, and are checked only with-studio: a badLTTR_SMTP_ADDRnever stops the language server itself.
The studio shows no "Rendering…" cue while a buffer rebuilds. At a 150 ms debounce and a build of about 40 ms, it would flicker on every keystroke. The pill and the ● updated cue already say that the preview follows the buffer.
VS Code
VS Code needs an extension to run a language server it doesn't know. Generic LSP Client (v2), extension ID zsol.vscode-glspc, runs any server from your settings. These steps were checked against its version 0.2.1:
code --install-extension zsol.vscode-glspc
Then, in the workspace's settings:
{
"glspc.server.command": "lttr",
"glspc.server.commandArguments": ["lsp"],
"glspc.server.languageId": ["markdown"]
}
For a typed app, run its studio program instead:
{
"glspc.server.command": "go",
"glspc.server.commandArguments": ["run", "./examples/tutorial/cmd/emaildev", "lsp"],
"glspc.server.languageId": ["markdown"]
}
- Open the module root. The extension starts the server in the window's first workspace folder, which is where
emaildev lspneeds to run. - One server per window. The extension runs one server, so a window uses either
lttr lsporemaildev lsp. - Restarts. A change to these settings restarts the server. Generic LSP Client: Restart server in the command palette does it by hand, after a Go change, say.
- Kit files. A kit's problems show in the Problems panel whatever the list says. For completion inside kit files too, add their language IDs to
glspc.server.languageId:yamlforkit.yamlandcomponent.yaml, and forhtml.tmplthe ID the Change Language Mode picker shows. A file whose extension VS Code doesn't know isplaintext. - Troubleshooting. The server's log is in the Generic LSP Client output channel.
"glspc.trace.server": "verbose"adds every message. If the server doesn't start, giveglspc.server.commandthe absolute path oflttr, such as the output ofcommand -v lttr.
Add -studio to the arguments to preview as you type: ["lsp", "-studio", "localhost:7070"].
Neovim
Neovim has an LSP client built in. On Neovim 0.11 and later, define the server with vim.lsp.config and turn it on with vim.lsp.enable:
vim.lsp.config('lttr', {
cmd = { 'lttr', 'lsp' },
filetypes = { 'markdown' },
root_markers = { 'go.mod', '.git' },
})
vim.lsp.enable('lttr')
For a typed app, start its studio program in the module root with cmd_cwd:
vim.lsp.config('emaildev', {
cmd = { 'go', 'run', './examples/tutorial/cmd/emaildev', 'lsp' },
cmd_cwd = '/path/to/your/module',
filetypes = { 'markdown' },
root_markers = { 'go.mod' },
})
vim.lsp.enable('emaildev')
Enable one of the two per project, not both, or every Markdown file gets two servers.
On Neovim 0.10, start the server from a FileType autocommand with vim.lsp.start:
vim.api.nvim_create_autocmd('FileType', {
pattern = 'markdown',
callback = function(ev)
vim.lsp.start({
name = 'lttr',
cmd = { 'lttr', 'lsp' },
root_dir = vim.fs.root(ev.buf, { 'go.mod', '.git' }),
})
end,
})
vim.fs.root is new in 0.10. On 0.8 and 0.9, write root_dir = vim.fs.dirname(vim.fs.find({ 'go.mod', '.git' }, { upward = true })[1]) instead.
- Check it attached with
:checkhealth vim.lsp(:checkhealth lspbefore 0.11). - Use it.
Khovers by default in Neovim 0.10+; on earlier versions, mapvim.lsp.buf.hover(). The other defaults:CTRL-]goes to the definition, andCTRL-X CTRL-Ocompletes in insert mode. On 0.11,graopens the code actions, where the quick fixes are; on earlier versions, mapvim.lsp.buf.code_action()yourself. Problems show as diagnostics. - Kit files. For completion in kit templates, add the filetype Neovim gives them to
filetypes(:set filetype?in one shows it), andyamlforkit.yaml. - The working directory is Neovim's own unless you set
cmd_cwd. It matters foremaildev lsp, for relative-kitand-dirpaths, and for-studiowithout-kit.
Add -studio to cmd to preview as you type: cmd = { 'lttr', 'lsp', '-studio', 'localhost:7070' }.
Zed
Zed needs an extension. It starts only language servers that Zed itself or an extension registers, and its settings cannot add a new one: an lsp entry for a name no extension registers is not allowed. Zed's own extension docs say a language server needs a few lines of Rust, and a Zed maintainer confirmed in April 2026 that settings alone won't do (zed-industries/zed issue #52653). There is no published lttr extension.
The shortest route is a local dev extension of three files. It needs Rust installed with rustup, which lets Zed add the wasm32-wasip2 target it builds extensions for.
id = "lttr-lsp"
name = "lttr language server"
version = "0.0.1"
schema_version = 1
authors = ["You <you@example.com>"]
description = "Runs lttr lsp for Markdown"
repository = "https://github.com/you/zed-lttr-lsp"
[language_servers.lttr]
name = "lttr"
languages = ["Markdown"]
[package]
name = "lttr-lsp"
version = "0.0.1"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
zed_extension_api = "0.7.0"
use zed_extension_api::{self as zed, settings::LspSettings};
struct LttrExtension;
impl zed::Extension for LttrExtension {
fn new() -> Self {
LttrExtension
}
// Starts `lttr lsp`, or the command in the "lsp" → "lttr" → "binary"
// setting: an app's own studio program, for example.
fn language_server_command(
&mut self,
id: &zed::LanguageServerId,
worktree: &zed::Worktree,
) -> zed::Result<zed::Command> {
let binary = LspSettings::for_worktree(id.as_ref(), worktree)
.ok()
.and_then(|s| s.binary);
let command = binary
.as_ref()
.and_then(|b| b.path.clone())
.or_else(|| worktree.which("lttr"))
.ok_or("lttr is not on your PATH: go install github.com/sulv-io/lttr/cmd/lttr@latest")?;
let args = binary
.as_ref()
.and_then(|b| b.arguments.clone())
.unwrap_or_else(|| vec!["lsp".into()]);
let env = binary
.and_then(|b| b.env)
.map(|e| e.into_iter().collect())
.unwrap_or_default();
Ok(zed::Command { command, args, env })
}
}
zed::register_extension!(LttrExtension);
Put the three files in one directory, then run zed: install dev extension from the command palette (or Install Dev Extension on the Extensions page) and pick that directory. Open a Markdown file, and the server starts. Zed's log (zed: open log) shows why if it doesn't.
With the extension in place, Zed's lsp setting passes other arguments, or another program:
{
"lsp": {
"lttr": {
"binary": {
"arguments": ["lsp", "-studio", "localhost:7070"]
}
}
}
}
Zed doesn't document the working directory it starts a server in, so start a typed app's program through a shell that changes to the module root first:
{
"lsp": {
"lttr": {
"binary": {
"path": "/bin/sh",
"arguments": ["-c", "cd /path/to/your/module && exec go run ./examples/tutorial/cmd/emaildev lsp"]
}
}
}
}
The extension above builds against zed_extension_api 0.7.0, the latest release when this page was written. Markdown in Zed has no language server of its own, so nothing else competes for these files.
Next steps
- Studio for the preview
-studioserves, and thestudiolibrary behindemaildev. - The lttr CLI for
lttr lsp's flags. - Build your own kit, whose tutorial kit binds a Go type.
Studio
lttr serve and the studio library. A live grid of every sample, a workbench with its problems, data, golden diff and test sends, the components page, the size budget, keyboard shortcuts, editor links, unsaved editor buffers and the security model.
Screenshots
make shoot, tools/shoot's flags, the contact sheet it builds, and why a horizontal scroll fails the run.