Typst LSP
A brand-new language server for Typst.
Features
- Syntax highlighting, error reporting, code completion, and function signature help
- Compiles to PDF on save (configurable to as-you-type, or can be disabled)
This repo consists of:
- an LSP server, written in Rust
- a corresponding VS Code(ium) extension. The extension is available on the VS Code Marketplace and OpenVSX.
Near future goals
- Improved preview (e.g. built-in PDF viewer, render to image for speed)
- Support for more editors
Development guide
Prerequisites
Install:
- Rust for the LSP itself
- Rust Analyzer an extension for Rust LSP for VS Code
- node for the VS Code extension; it may be easiest to install via fnm
First time setup
- Clone this repository locally
- Open it in VS Code; it's needed to run the extension
- In the
addons/vscode
subdirectory:- Run
npm install
to install extension dependencies - Run
npm run compile
to build the extension
- Run
- Run through the development cycle once to initialize and test everything
- (Optional: install the dev version of the extension): Press Ctrl+Shift+P, and choose
Developer: Install Extension from Location...
and choose the directory for the extension,addons/vscode/
. There will not be any messages, but the extension can be found in the Extensions@installed
list.
Development cycle
- Make any changes
- Run
cargo install --path .
; at present, the VS Code extension just invokes thetypst-lsp
command to start the LSP, and this command will compile and replace that binary with the latest version- If modifying the extension, keep
npm run watch
running, ornpm run compile
after changes
- If modifying the extension, keep
- Press Ctrl+F5 to launch the "Extension Development Host"; if it's already running, invoke "Developer: Reload Window" from the command palette in the Extension Development Host
- Within the Extension Development Host, the extension will be active and ready for testing