diff --git a/lua/config/lspconfig.lua b/lua/config/lspconfig.lua index 0d10f18..348a56f 100644 --- a/lua/config/lspconfig.lua +++ b/lua/config/lspconfig.lua @@ -33,6 +33,34 @@ if not configs.elixirls then } end +-- typst-lsp + +if not configs.typst_lsp then + configs.typst_lsp = { + default_config = { + cmd = { 'typst-lsp' }, + filetypes = { 'typst' }, + single_file_support = true, + root_dir = function(fname) + return nvim_lsp.util.find_git_ancestor(fname) + end, + }, + docs = { + description = [[ +https://github.com/nvarner/typst-lsp + +Language server for Typst. + ]], + }, + } +end + +require 'lspconfig'.typst_lsp.setup { + settings = { + exportPdf = "onSave", + } +} + -- keybindings local on_attach = function(client, bufrn) @@ -90,6 +118,7 @@ local servers = { -- 'denols', 'clangd', 'zls', + 'typst-lsp', } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { diff --git a/lua/config/treesitter.lua b/lua/config/treesitter.lua index 3319d59..29015e3 100644 --- a/lua/config/treesitter.lua +++ b/lua/config/treesitter.lua @@ -40,3 +40,18 @@ parser_config.hare = { } vim.treesitter.language.register('hare', 'hare') + +-- typst syntax +-- parser_config.typst = { +-- install_info = { +-- url = "~/code/typst/tree-sitter-typst", -- local path or git repo +-- files = {"src/parser.c", "src/scanner.cc"}, -- note that some parsers also require src/scanner.c or src/scanner.cc +-- -- optional entries: +-- -- branch = "main", -- default branch in case of git repo if different from master +-- generate_requires_npm = true, -- if stand-alone parser without npm dependencies +-- requires_generate_from_grammar = true, -- if folder contains pre-generated src/parser.c +-- }, +-- filetype = "typ", -- if filetype does not match the parser name +-- } +-- +-- vim.treesitter.language.register('typst', 'typ') diff --git a/lua/plugins.lua b/lua/plugins.lua index 0553ad8..18a7032 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -148,6 +148,10 @@ local function init() -- RFC browser use 'mhinz/vim-rfc' + + -- typst + use 'kaarmu/typst.vim' + use 'nvarner/typst-lsp' end local plugins = setmetatable({}, {