
* dev: split a gh-release profile to accelerate development * fix: many typos * fix: miri warnings * fix: update fixtures
3.3 KiB
Tinymist Neovim Support for Typst
Run and configure tinymist in neovim for Typst.
Features
See Tinymist Features for a list of features.
Finding Executable
To enable LSP, you must install tinymist
. You can find tinymist
on:
-
Night versions available at GitHub Actions.
-
Stable versions available with mason.nvim.
{ "williamboman/mason.nvim", opts = { ensure_installed = { "tinymist", }, }, }
-
Stable versions available at GitHub Releases.
You can also compile and install latest tinymist
by Cargo.
cargo install --git https://github.com/Myriad-Dreamin/tinymist --locked
Minimal Setup: LazyVim as an Example
This section shows you a minimal way to setup tinymist in Neovim (LazyVim).
-
Copy or merge the Autocmds file and Plugin file to corresponding paths into
~/.config/nvim/
. -
Check and restart Neovim.
Please see Extra Settings for more configuration.
Tips
Working with Multiple-File Projects
The solution is a bit internal, which should get further improvement, but you can pin a main file by command.
# pin the main file
vim.lsp.buf.execute_command({ command = 'tinymist.pinMain', arguments = { vim.api.nvim_buf_get_name(0) } })
# unpin the main file
vim.lsp.buf.execute_command({ command = 'tinymist.pinMain', arguments = { nil } })
There is also a plan to support multiple-file project by workspace configuration, but I don't know what is neovim's way, so it needs further discussion.
Troubleshooting
tinymist does not start on creating/opening files
First, please check that tinymist can start with manual file association.
:set filetype=typst
If tinymist starts, that means you have not made correct file association. If not, there should be some errors in your lspconfig.
Please associate .typ
file extension to typst
filetype to start tinymist on creating/opening file events.
autocmd BufNewFile,BufRead *.typ setfiletype typst
Extra Settings
Configuring LSP Server
To configure LSP server, you can edit the opts.servers.tinymist.settings
. For example, if you want to export PDF on typing and output files in $root_dir/target
directory:
return {
-- add tinymist to lspconfig
{
"neovim/nvim-lspconfig",
opts = {
servers = {
tinymist = {
settings = {
exportPdf = "onType",
outputPath = "$root/target/$dir/$name",
}
},
},
},
},
}
See Tinymist Server Configuration for references.
Configuring Folding Range for Neovim Client
Enable LSP-based folding range with kevinhwang91/nvim-ufo
:
return {
{ -- configure LSP servers
"neovim/nvim-lspconfig",
dependencies = "kevinhwang91/nvim-ufo", -- enable LSP-based folds
},
}
You can copy or merge lsp-folding.lua to corresponding paths into ~/.config/nvim/
and restart Neovim.
Contributing
You can submit issues or make PRs to GitHub.