Language server
Editor features for .sveltex files — hover, completion, diagnostics, outline — across every editor that speaks LSP.
.sveltex files are not a single language: they intermix Svelte (markup, <script>, <style>, mustache tags, logic blocks) with Markdown, and are punctuated by verbatim regions — fenced code, math ($…$, $$…$$, \(…\), \[…\]), and LaTeX environments — that must not be interpreted as Svelte. The @nvl/sveltex-language-server package gives each region the treatment it deserves.
Full Svelte tooling, proxied: Diagnostics, hover, completion, go-to-definition, find references, document highlight, code actions, rename, signature help, and document links — all forwarded to the upstream
svelte-language-server, fully position-mapped to the source.sveltexfile. Anything that lands in a verbatim region is suppressed so you don't see spurious "unexpected$" diagnostics inside a math block.TeX command completion in math: Type
\alinside$…$and get\alphaand friends, with rich hover showing each command's signature, the Unicode symbol it renders, and a description. The offered commands match the project'smathBackend(KaTeX vs MathJax), via the bundled@nvl/sveltex-math-language-server.Frontmatter hover & completion: Every recognised frontmatter key (
title,meta,base,link,imports, …) and every standard<meta>name documents itself on hover, with a link to MDN. Completion offers the right keys for the block the caret sits in.Heading outline & folding: The Markdown headings of a
.sveltexfile populate the editor's outline view; folding ranges and structured selection ranges match the source's heading and block structure.LaTeX features in
texverbatim (optional): When TexLab is onPATH, hover and completion inside<tex>/<latex>/<tikz>environments are forwarded to it. If TexLab isn't installed, these regions are skipped silently.Auto-configured: Reads
svelte.config.{js,mjs,cjs,ts,mts,cts}from the workspace root to discover your SvelTeX configuration (verbatim environment names, math delimiters, math backend, …) and live-reloads when the config or one of its imports changes.
Installation
VS Code
Install the official extension from the Marketplace:
code --install-extension sveltex-preprocessor.sveltex(or search "SvelTeX" in the Extensions sidebar — the extension is published as sveltex-preprocessor.sveltex and bundles the language server, so there's no separate setup step.)
The extension activates for any .sveltex file. The first activation spawns the language server in the background; output goes to the SvelTeX Language Server output channel if you need to debug.
Zed
A Zed extension lives at editors/zed in the SvelTeX repo and is published to the Zed extension registry as "SvelTeX" — install it from Zed's extensions panel (Cmd+Shift+X → search "SvelTeX"). The extension launches the same @nvl/sveltex-language-server and speaks LSP over stdio.
Other editors
The language server is editor-agnostic. Any LSP-aware editor (Neovim, Emacs lsp-mode, Sublime LSP, Helix, …) can launch it as a child process that speaks LSP over stdio:
Install the server:
shnpm install -g @nvl/sveltex-language-serverConfigure your editor's LSP client to spawn
sveltex-language-server(or, ifnpmdidn't add it to yourPATH, thebin/server.jsit ships) for files matching**/*.sveltex.
For a worked example of how a third-party editor launches the server, see the Zed extension's manifest and editors/zed/src/lib.rs — both spawn bin/server.js over stdio.
Configuration
The language server has no configuration of its own — it reads your project's SvelTeX configuration directly from svelte.config.{js,mjs,cjs,ts,mts,cts} on the first request and re-reads whenever the file (or anything it imports) changes.
What the server picks up from there:
- the verbatim environment names and aliases (so hover and completion know which tags carve out non-delegated regions);
- the math delimiters and
mathBackend(which spawns the correct math language server — KaTeX or MathJax — for command completion); - the markdown directives settings (for the region detector).
Anything else (TeX compilation settings, output paths, caching) is runtime-only and never needed by the language server.
TIP
If the language server can't find a svelte.config.*, it falls back to SvelTeX's implicit defaults and logs a notice to the output channel — the server still works, but verbatim tags you've configured won't be recognised. Add a svelte.config.js at the workspace root that imports your SvelTeX configuration.
Companion: @nvl/sveltex-math-language-server
Math-only LSP that does TeX command completion and hover inside math regions. Bundled with @nvl/sveltex-language-server — there's nothing to install separately; the parent server spawns it on demand based on your project's mathBackend. Useful as a standalone server too (for editors that want math features in plain .tex / .md files).
Troubleshooting
The server doesn't start. Check the editor's LSP / output channel for an error. The extension keeps syntax highlighting working even if the server fails, so the absence of hover / completion is the only outward symptom.
TeX command completion is missing inside
$…$. The math backend is'none'or'custom'— neither has a corresponding math server. SetmathBackendto'katex'or'mathjax'.No completion inside
<tex>/<latex>/<tikz>. The server forwards LaTeX-verbatim regions to TexLab; iftexlabisn't onPATH, these regions are silently skipped. Install TexLab and restart your editor.Diagnostics for math / LaTeX are missing. Not implemented yet — math and LaTeX verbatim regions get completion and hover but no diagnostics. The full Svelte / TypeScript / CSS diagnostic stream still works in delegated regions.
For implementation details — region detection, the virtual-document strategy, position mapping — see the @nvl/sveltex-language-server README.