diff --git a/docs/src/language_servers.md b/docs/src/language_servers.md index 5a704b738..ee2a069d3 100644 --- a/docs/src/language_servers.md +++ b/docs/src/language_servers.md @@ -778,35 +778,90 @@ See [Javascript/TypeScript](#javascripttypescript). ## Typst 1. Install the [Typst](https://packagecontrol.io/packages/Typst) package from Package Control for syntax highlighting. -2. Download the [typst-lsp](https://github.com/nvarner/typst-lsp/releases) language server executable for your platform. -3. Open `Preferences > Package Settings > LSP > Settings` and add the `"typst-lsp"` client configuration to the `"clients"`: +2. Optional: to enable auto-completions for the relevant situations in Typst files, adjust Sublime's `"auto_complete_selector"` and/or `"auto_complete_triggers"` setting (`Preferences > Settings`); for example + + ```jsonc + { + "auto_complete_triggers": + [ + {"selector": "text.html, text.xml", "characters": "<"}, + {"selector": "punctuation.accessor", "rhs_empty": true}, + {"selector": "text.typst", "characters": "#", "rhs_empty": true}, + ], + } + ``` + +There are 2 available languages servers. + +### Tinymist + +This server has more features, like go to definition, rename, etc. + +1. Install [tinymist](https://github.com/Myriad-Dreamin/tinymist). +2. Open `Preferences > Package Settings > LSP > Settings` and add the `"tinymist"` client configuration to the `"clients"`: ```jsonc { "clients": { - "typst-lsp": { + "tinymist": { "enabled": true, - "command": ["C:\\path\\to\\typst-lsp-win32-x64.exe"], // adjust this path according to your platform/setup - "selector": "text.typst" + "command": ["path/to/tinymist"], // adjust this path according to your platform/setup + "selector": "text.typst", + // you can provide some initialization options: + "initializationOptions": { + "exportPdf": "never", + "typstExtraArgs": [], + }, } } } ``` -4. Optional: to enable auto-completions for the relevant situations in Typst files, adjust Sublime's `"auto_complete_selector"` and/or `"auto_complete_triggers"` setting (`Preferences > Settings`); for example +3. Optional: to enable some useful commands provided by language server, add the following to the `*.sublime-commands`: + + + ```jsonc title="Packages/User/Default.sublime-commands" + [ + // ... + { + "caption": "tinymist - Pin the main file to the currently opened document", + "command": "lsp_execute", + "args": { + "session_name": "tinymist", + "command_name": "tinymist.pinMain", + "command_args": ["${file}"] + } + }, + { + "caption": "tinymist - Unpin the main file", + "command": "lsp_execute", + "args": { + "session_name": "tinymist", + "command_name": "tinymist.pinMain", + "command_args": [null] + } + }, + ] + ``` + +### Typst-lsp + +1. Install [typst-lsp](https://github.com/nvarner/typst-lsp/releases). +2. Open `Preferences > Package Settings > LSP > Settings` and add the `"typst-lsp"` client configuration to the `"clients"`: ```jsonc { - "auto_complete_triggers": - [ - {"selector": "text.html, text.xml", "characters": "<"}, - {"selector": "punctuation.accessor", "rhs_empty": true}, - {"selector": "text.typst", "characters": "#", "rhs_empty": true}, - ], + "clients": { + "typst-lsp": { + "enabled": true, + "command": ["path/to/typst-lsp"], // adjust this path according to your platform/setup + "selector": "text.typst" + } + } } ``` -5. Optional: to enable some useful commands provided by language server, add the following to the `*.sublime-commands`: +3. Optional: to enable some useful commands provided by language server, add the following to the `*.sublime-commands`: ```jsonc title="Packages/User/Default.sublime-commands"