From 35e545378a93eb427214a4ad2aadf327742b2d26 Mon Sep 17 00:00:00 2001 From: Vo Quang Chien Date: Mon, 15 Jul 2024 10:43:37 +0700 Subject: [PATCH 01/16] feat(lang): add Typst language support --- lua/lazyvim/plugins/extras/lang/typst.lua | 53 +++++++++++++++++++++++ 1 file changed, 53 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..2bbc7ab3 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -0,0 +1,53 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = { "typst" }, + }) + end, + + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { "typst" }, + }, + }, + + -- Wait until this package is available in the mason-registry + -- { + -- "williamboman/mason.nvim", + -- opts = { + -- ensure_installed = { "typstyle" }, + -- }, + -- }, + + { + "neovim/nvim-lspconfig", + opts = { + servers = { + tinymist = {}, + }, + }, + }, + + { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + typst = { "typstyle" }, + }, + }, + }, + + { + "chomosuke/typst-preview.nvim", + cmd = { "TypstPreview" }, + build = function() + require("typst-preview").update() + end, + opts = { + dependencies_bin = { + ["typst-preview"] = "tinymist", + }, + }, + }, +} From 51a0452c97dce5fdbc64fe0e91c75ff016b026c1 Mon Sep 17 00:00:00 2001 From: Vo Quang Chien Date: Mon, 15 Jul 2024 14:05:07 +0700 Subject: [PATCH 02/16] chore(typst): add `optional = true` to conform.nvim --- lua/lazyvim/plugins/extras/lang/typst.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index 2bbc7ab3..20b61fe2 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -31,6 +31,7 @@ return { { "stevearc/conform.nvim", + optional = true, opts = { formatters_by_ft = { typst = { "typstyle" }, From 3b88644561fcff4ead4eb1eef87d59f94ef19ced Mon Sep 17 00:00:00 2001 From: Vo Quang Chien Date: Mon, 15 Jul 2024 14:06:14 +0700 Subject: [PATCH 03/16] feat(typst): add none-ls config --- lua/lazyvim/plugins/extras/lang/typst.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index 20b61fe2..361347d1 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -39,6 +39,17 @@ return { }, }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.formatting.typstyle, + }) + end, + }, + { "chomosuke/typst-preview.nvim", cmd = { "TypstPreview" }, From 4400ee31b9397be1cd3c447a0d15b64ea0d9e417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=B5=20Quang=20Chi=E1=BA=BFn?= Date: Fri, 13 Sep 2024 08:35:22 +0700 Subject: [PATCH 04/16] chore(typst): uncomment code --- lua/lazyvim/plugins/extras/lang/typst.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index 361347d1..0357d70a 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -12,13 +12,12 @@ return { }, }, - -- Wait until this package is available in the mason-registry - -- { - -- "williamboman/mason.nvim", - -- opts = { - -- ensure_installed = { "typstyle" }, - -- }, - -- }, + { + "williamboman/mason.nvim", + opts = { + ensure_installed = { "typstyle" }, + }, + }, { "neovim/nvim-lspconfig", From f498290e11dfd868f0d4d1929df585242c0ebaeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=B5=20Quang=20Chi=E1=BA=BFn?= Date: Thu, 19 Sep 2024 05:07:40 +0700 Subject: [PATCH 05/16] feat(typst): add Typst preview keymap to `typst-preview.nvim` Co-authored-by: Jose Storopoli --- lua/lazyvim/plugins/extras/lang/typst.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index 0357d70a..63d8b1ae 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -55,6 +55,14 @@ return { build = function() require("typst-preview").update() end, + keys = { + { + "cp", + ft = "typst", + "TypstPreviewToggle", + desc = "Typst Preview", + }, + }, opts = { dependencies_bin = { ["typst-preview"] = "tinymist", From 837ed5774554aa95cdae97fb4c72aaa2e61d32c2 Mon Sep 17 00:00:00 2001 From: Vo Quang Chien Date: Tue, 29 Oct 2024 08:31:02 +0700 Subject: [PATCH 06/16] feat(typst): use builtin lsp formatter --- lua/lazyvim/plugins/extras/lang/typst.lua | 38 +++++------------------ 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index 63d8b1ae..adea7cdb 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -12,46 +12,22 @@ return { }, }, - { - "williamboman/mason.nvim", - opts = { - ensure_installed = { "typstyle" }, - }, - }, - { "neovim/nvim-lspconfig", opts = { servers = { - tinymist = {}, + tinymist = { + settings = { + formatterMode = "typstyle", + }, + }, }, }, }, - { - "stevearc/conform.nvim", - optional = true, - opts = { - formatters_by_ft = { - typst = { "typstyle" }, - }, - }, - }, - - { - "nvimtools/none-ls.nvim", - optional = true, - opts = function(_, opts) - local nls = require("null-ls") - opts.sources = vim.list_extend(opts.sources or {}, { - nls.builtins.formatting.typstyle, - }) - end, - }, - { "chomosuke/typst-preview.nvim", - cmd = { "TypstPreview" }, + cmd = { "TypstPreview", "TypstPreviewToggle", "TypstPreviewUpdate" }, build = function() require("typst-preview").update() end, @@ -65,7 +41,7 @@ return { }, opts = { dependencies_bin = { - ["typst-preview"] = "tinymist", + tinymist = "tinymist", }, }, }, From 1ea189f9bbb28b275918ef194489622207f95bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=B5=20Quang=20Chi=E1=BA=BFn?= Date: Sat, 2 Nov 2024 16:07:47 +0700 Subject: [PATCH 07/16] revert(typst): restore conform configuration Co-authored-by: Stefan Boca <45266795+stefanboca@users.noreply.github.com> --- lua/lazyvim/plugins/extras/lang/typst.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index adea7cdb..a61d1cb7 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -25,6 +25,16 @@ return { }, }, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + typst = { "typstyle", lsp_format = "prefer" }, + }, + }, + }, + { "chomosuke/typst-preview.nvim", cmd = { "TypstPreview", "TypstPreviewToggle", "TypstPreviewUpdate" }, From 4a7e80c4aa3a978712e994c4bcb44160090d8945 Mon Sep 17 00:00:00 2001 From: Vo Quang Chien Date: Sat, 2 Nov 2024 16:50:31 +0700 Subject: [PATCH 08/16] fix(typst): prevent redundant download of tinymist binary in typst-preview --- lua/lazyvim/plugins/extras/lang/typst.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index a61d1cb7..49645ca1 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -38,8 +38,10 @@ return { { "chomosuke/typst-preview.nvim", cmd = { "TypstPreview", "TypstPreviewToggle", "TypstPreviewUpdate" }, - build = function() - require("typst-preview").update() + build = function(plugin) + local typst_preview = require("typst-preview") + typst_preview.setup(plugin.opts) + typst_preview.update() end, keys = { { From 2daa8da842b1e687e0bdf6950f42a4aebc5e9b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=B5=20Quang=20Chi=E1=BA=BFn?= Date: Fri, 8 Nov 2024 08:56:14 +0700 Subject: [PATCH 09/16] fix(typst): enable single file support Co-authored-by: Stefan Boca <45266795+stefanboca@users.noreply.github.com> --- lua/lazyvim/plugins/extras/lang/typst.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index 49645ca1..58868230 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -17,6 +17,10 @@ return { opts = { servers = { tinymist = { + single_file_support = true, + root_dir = function() + LazyVim.root.get() + end, settings = { formatterMode = "typstyle", }, From d281c79dee806b2370b7ea193cfe6ed55ab6d240 Mon Sep 17 00:00:00 2001 From: Vo Quang chien Date: Fri, 8 Nov 2024 09:09:27 +0700 Subject: [PATCH 10/16] chore(typst): add comments and simplify code --- lua/lazyvim/plugins/extras/lang/typst.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index 58868230..1940a526 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -17,10 +17,8 @@ return { opts = { servers = { tinymist = { - single_file_support = true, - root_dir = function() - LazyVim.root.get() - end, + single_file_support = true, -- Fixes LSP attachment in non-Git directories + root_dir = LazyVim.root.get, settings = { formatterMode = "typstyle", }, @@ -44,7 +42,7 @@ return { cmd = { "TypstPreview", "TypstPreviewToggle", "TypstPreviewUpdate" }, build = function(plugin) local typst_preview = require("typst-preview") - typst_preview.setup(plugin.opts) + typst_preview.setup(plugin.opts) -- Setup preview during build to avoid redundant downloads typst_preview.update() end, keys = { @@ -52,7 +50,7 @@ return { "cp", ft = "typst", "TypstPreviewToggle", - desc = "Typst Preview", + desc = "Toggle Typst Preview", }, }, opts = { From 325b588324cb0946fa33231b6aea077395356f49 Mon Sep 17 00:00:00 2001 From: Vo Quang chien Date: Fri, 8 Nov 2024 20:48:33 +0700 Subject: [PATCH 11/16] chore(typst): don't set root_dir in lspconfig --- lua/lazyvim/plugins/extras/lang/typst.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index 1940a526..ffdc6228 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -18,7 +18,6 @@ return { servers = { tinymist = { single_file_support = true, -- Fixes LSP attachment in non-Git directories - root_dir = LazyVim.root.get, settings = { formatterMode = "typstyle", }, From e6f6db26675a7d26ea00d17a709c1b8b961addd3 Mon Sep 17 00:00:00 2001 From: Vo Quang chien Date: Wed, 20 Nov 2024 09:25:53 +0700 Subject: [PATCH 12/16] fix(typst): remove `build` for `typst-preview` plugin now downloads binaries during setup --- lua/lazyvim/plugins/extras/lang/typst.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index ffdc6228..b174deb0 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -39,11 +39,6 @@ return { { "chomosuke/typst-preview.nvim", cmd = { "TypstPreview", "TypstPreviewToggle", "TypstPreviewUpdate" }, - build = function(plugin) - local typst_preview = require("typst-preview") - typst_preview.setup(plugin.opts) -- Setup preview during build to avoid redundant downloads - typst_preview.update() - end, keys = { { "cp", From 50ebce1a7b830fd269dfa55a345f8a00088c3638 Mon Sep 17 00:00:00 2001 From: Vo Quang Chien Date: Mon, 9 Dec 2024 08:42:32 +0700 Subject: [PATCH 13/16] fix(typst): add typst comment string --- lua/lazyvim/plugins/extras/lang/typst.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index b174deb0..f859af9f 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -53,4 +53,9 @@ return { }, }, }, + + { + "folke/ts-comments.nvim", + opts = { lang = { typst = "// %s" } }, + }, } From 979a8c6557578cab2ab62ef4951584692b461873 Mon Sep 17 00:00:00 2001 From: Vo Quang Chien Date: Fri, 20 Dec 2024 08:55:19 +0700 Subject: [PATCH 14/16] feat(typst): add block-scope comment string --- lua/lazyvim/plugins/extras/lang/typst.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index f859af9f..9a19e47e 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -56,6 +56,10 @@ return { { "folke/ts-comments.nvim", - opts = { lang = { typst = "// %s" } }, + opts = { + lang = { + typst = { "// %s", "/* %s */" }, + }, + }, }, } From 3a59edf56c45fcee230e5bdf16a505b704bcf282 Mon Sep 17 00:00:00 2001 From: Vo Quang Chien Date: Fri, 20 Dec 2024 09:34:10 +0700 Subject: [PATCH 15/16] feat(typst): add keymap to define entry point of the project --- lua/lazyvim/plugins/extras/lang/typst.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index 9a19e47e..8fdbb35c 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -17,6 +17,19 @@ return { opts = { servers = { tinymist = { + keys = { + { + "cP", + function() + local buf_name = vim.api.nvim_buf_get_name(0) + LazyVim.lsp.execute({ + command = "tinymist.pinMain", + arguments = { buf_name }, + }) + end, + desc = "Pin main file", + }, + }, single_file_support = true, -- Fixes LSP attachment in non-Git directories settings = { formatterMode = "typstyle", From e432206114bb91b475f395a7a103c27906fcabdc Mon Sep 17 00:00:00 2001 From: Vo Quang Chien Date: Wed, 21 May 2025 11:36:05 +0700 Subject: [PATCH 16/16] feat(typst): notify when a file is pinned --- lua/lazyvim/plugins/extras/lang/typst.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/typst.lua b/lua/lazyvim/plugins/extras/lang/typst.lua index 8fdbb35c..099a6861 100644 --- a/lua/lazyvim/plugins/extras/lang/typst.lua +++ b/lua/lazyvim/plugins/extras/lang/typst.lua @@ -22,10 +22,12 @@ return { "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", },