diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2025-08-11 16:49:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-11 16:49:46 -0400 |
| commit | 0e3083e961a5c73854cbab381c1cbb6652cee6a6 (patch) | |
| tree | 6dd7b428c378de9e3d171da973ab5ecee0360c24 /lsp/tinymist.lua | |
| parent | docs: update configs.md (diff) | |
| parent | fix(tinymist): update config to 0.11+ (diff) | |
| download | nvim-lspconfig-0e3083e961a5c73854cbab381c1cbb6652cee6a6.tar nvim-lspconfig-0e3083e961a5c73854cbab381c1cbb6652cee6a6.tar.gz nvim-lspconfig-0e3083e961a5c73854cbab381c1cbb6652cee6a6.tar.bz2 nvim-lspconfig-0e3083e961a5c73854cbab381c1cbb6652cee6a6.tar.lz nvim-lspconfig-0e3083e961a5c73854cbab381c1cbb6652cee6a6.tar.xz nvim-lspconfig-0e3083e961a5c73854cbab381c1cbb6652cee6a6.tar.zst nvim-lspconfig-0e3083e961a5c73854cbab381c1cbb6652cee6a6.zip | |
Merge #3993 fix: update configs to 0.11+
* fix(zk): update config to 0.11+
- Remove buf.execute_command in favor of :exec_cmd
- Set title on :exec_cmd
* fix(clangd): update config to 0.11+
- Use client and bufnr as arguments of on_attach
- Silence wrong diagnostics about unknown method
- Call request as method
- Align the style of the two functions
- Drop border setup in favor of winborder option
* fix(denols): update config to 0.11+
- Call request_sync as method
- Use vim.notify instead of nvim_err_writeln
* fix(elmls): update config to 0.11+
- Use vim.bo[bufnr] instead of nvim_buf_get_option
* fix(markdown_oxide): update config to 0.11+
- Use drop buf.execute command and use :exec_cmd
* fix(rust_analyzer): update config to 0.11+
- Call request as method
- Silence wrong diagnostic
* fix(svlangserver): update config to 0.11+
- Drop .buf.execute_command and use :exec_cmd
* fix(texlab): update config to 0.11+
- Use bufnr and client as arguments of on_attach
- Update documentation to indicate implemented commands
* fix(tinymist): update config to 0.11+
- Drop check for neovim version
- Make sure the name starts with Lsp to remove the exemption from the CI
check
Diffstat (limited to 'lsp/tinymist.lua')
| -rw-r--r-- | lsp/tinymist.lua | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lsp/tinymist.lua b/lsp/tinymist.lua index 3b182a67..67812a55 100644 --- a/lsp/tinymist.lua +++ b/lsp/tinymist.lua @@ -11,6 +11,8 @@ --- `LspTinymistGetDocumentMetrics`. ---@param command_name string +---@param client vim.lsp.Client +---@param bufnr integer ---@return fun():nil run_tinymist_command, string cmd_name, string cmd_desc local function create_tinymist_command(command_name, client, bufnr) local export_type = command_name:match 'tinymist%.export(%w+)' @@ -19,7 +21,6 @@ local function create_tinymist_command(command_name, client, bufnr) info_type = info_type:gsub('^get', 'Get') end local cmd_display = export_type or info_type - ---Execute the Tinymist command, supporting both 0.10 and 0.11 exec methods ---@return nil local function run_tinymist_command() local arguments = { vim.api.nvim_buf_get_name(bufnr) } @@ -32,19 +33,14 @@ local function create_tinymist_command(command_name, client, bufnr) -- If exporting, show the string result; else, show the table for inspection vim.notify(export_type and res or vim.inspect(res), vim.log.levels.INFO) end - if vim.fn.has 'nvim-0.11' == 1 then - -- For Neovim 0.11+ - return client:exec_cmd({ - title = title_str, - command = command_name, - arguments = arguments, - }, { bufnr = bufnr }, handler) - else - return vim.notify('Tinymist commands require Neovim 0.11+', vim.log.levels.WARN) - end + return client:exec_cmd({ + title = title_str, + command = command_name, + arguments = arguments, + }, { bufnr = bufnr }, handler) end -- Construct a readable command name/desc - local cmd_name = export_type and ('LspTinymistExport' .. cmd_display) or ('LspTinymist' .. cmd_display) ---@type string + local cmd_name = export_type and ('TinymistExport' .. cmd_display) or ('Tinymist' .. cmd_display) ---@type string local cmd_desc = export_type and ('Export to ' .. cmd_display) or ('Get ' .. cmd_display) ---@type string return run_tinymist_command, cmd_name, cmd_desc end @@ -53,6 +49,8 @@ return { cmd = { 'tinymist' }, filetypes = { 'typst' }, root_markers = { '.git' }, + ---@param client vim.lsp.Client + ---@param bufnr integer on_attach = function(client, bufnr) for _, command in ipairs { 'tinymist.exportSvg', @@ -69,7 +67,7 @@ return { 'tinymist.getDocumentMetrics', } do local cmd_func, cmd_name, cmd_desc = create_tinymist_command(command, client, bufnr) - vim.api.nvim_buf_create_user_command(bufnr, cmd_name, cmd_func, { nargs = 0, desc = cmd_desc }) + vim.api.nvim_buf_create_user_command(bufnr, 'Lsp' .. cmd_name, cmd_func, { nargs = 0, desc = cmd_desc }) end end, } |
