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 <jose@storopoli.io>
Co-authored-by: Stefan Boca <45266795+stefanboca@users.noreply.github.com>
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
Vo Quang Chien
2025-10-20 15:23:30 +07:00
committed by GitHub
parent a6eb51e5b5
commit 645846be5c

View File

@@ -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 = {
{
"<leader>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 = {
{
"<leader>cp",
ft = "typst",
"<cmd>TypstPreviewToggle<cr>",
desc = "Toggle Typst Preview",
},
},
opts = {
dependencies_bin = {
tinymist = "tinymist",
},
},
},
{
"folke/ts-comments.nvim",
opts = {
lang = {
typst = { "// %s", "/* %s */" },
},
},
},
}