fix typst pin

This commit is contained in:
cscherr 2025-05-05 11:55:17 +02:00
parent cebf16e11d
commit 6ce682a3fc
Signed by: cscherrNT
GPG key ID: 8E2B45BC51A27EA7
3 changed files with 20 additions and 7 deletions

View file

@ -172,9 +172,6 @@ end, {
desc = 'Enable autoformat',
bang = true,
})
vim.api.nvim_create_user_command('TypstPinMain', function()
vim.lsp.buf.execute_command { command = 'tinymist.pinMain', arguments = { vim.api.nvim_buf_get_name(0) } }
end, { nargs = 0 })
-- autocommands
-- ===

View file

@ -98,9 +98,6 @@ vim.api.nvim_create_autocmd('FileType', {
'typst',
},
callback = function()
-- 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 } }
print "Don't forget to pin the main typst file for multifile support: <leader>tp"
end,
})

View file

@ -146,6 +146,23 @@ local servers = {
exportPdf = 'never',
semanticTokens = 'disable',
},
on_attach = function(client, bufnr)
vim.keymap.set('n', '<leader>tp', function()
client:exec_cmd({
title = 'pin',
command = 'tinymist.pinMain',
arguments = { vim.api.nvim_buf_get_name(0) },
}, { bufnr = bufnr })
end, { desc = '[T]oggle [P]in (pin this file as main file)', noremap = true })
vim.keymap.set('n', '<leader>tu', function()
client:exec_cmd({
title = 'unpin',
command = 'tinymist.pinMain',
arguments = { vim.v.null },
}, { bufnr = bufnr })
end, { desc = '[T]oggle [U]npin (unpin this file as main file)', noremap = true })
end,
},
html = {},
ts_ls = {},
@ -208,6 +225,8 @@ vim.list_extend(ensure_installed, {
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
require('mason-lspconfig').setup {
ensure_installed = nil,
automatic_installation = true,
handlers = {
function(server_name)
local server = servers[server_name] or {}