From 645846be5c7d798c7e87e61d00e8cae4fd3741c7 Mon Sep 17 00:00:00 2001 From: Vo Quang Chien Date: Mon, 20 Oct 2025 15:23:30 +0700 Subject: [PATCH] feat(lang): add Typst language support (#4042) ## Description This pull request introduces robust support for the [Typst](https://github.com/typst/typst) language in LazyVim, enhancing the Typst editing experience with several integrated tools: 1. **LSP Support**: Integrate with [tinymist](https://github.com/Myriad-Dreamin/tinymist) provides comprehensive LSP support. 2. **Code Formatting**: Integrate with [typstyle](https://github.com/Enter-tainer/typstyle) for code formatting. 3. **Preview Support**: Added [typst-preview.nvim](https://github.com/chomosuke/typst-preview.nvim) for live preview of Typst documents. ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --------- Co-authored-by: Jose Storopoli Co-authored-by: Stefan Boca <45266795+stefanboca@users.noreply.github.com> Co-authored-by: Folke Lemaitre --- lua/lazyvim/plugins/extras/lang/typst.lua | 80 +++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/typst.lua diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua new file mode 100644 index 00000000..099a6861 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -0,0 +1,80 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = { "typst" }, + }) + end, + + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { "typst" }, + }, + }, + + { + "neovim/nvim-lspconfig", + opts = { + servers = { + tinymist = { + keys = { + { + "cP", + function() + local buf_name = vim.api.nvim_buf_get_name(0) + local file_name = vim.fn.fnamemodify(buf_name, ":t") + LazyVim.lsp.execute({ + command = "tinymist.pinMain", + arguments = { buf_name }, + }) + LazyVim.info("Tinymist: Pinned " .. file_name) + end, + desc = "Pin main file", + }, + }, + single_file_support = true, -- Fixes LSP attachment in non-Git directories + settings = { + formatterMode = "typstyle", + }, + }, + }, + }, + }, + + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + typst = { "typstyle", lsp_format = "prefer" }, + }, + }, + }, + + { + "chomosuke/typst-preview.nvim", + cmd = { "TypstPreview", "TypstPreviewToggle", "TypstPreviewUpdate" }, + keys = { + { + "cp", + ft = "typst", + "TypstPreviewToggle", + desc = "Toggle Typst Preview", + }, + }, + opts = { + dependencies_bin = { + tinymist = "tinymist", + }, + }, + }, + + { + "folke/ts-comments.nvim", + opts = { + lang = { + typst = { "// %s", "/* %s */" }, + }, + }, + }, +}