fix(util.lsp): LazyVim.lsp.execute only request single client

This commit is contained in:
Iordanis Petkakis 2025-12-27 18:46:47 +02:00
parent c64a61734f
commit 6a1428a102
4 changed files with 22 additions and 2 deletions

View file

@ -16,6 +16,8 @@ return {
function()
local params = vim.lsp.util.make_position_params()
LazyVim.lsp.execute({
title = "toPipe",
filter = "elixirls",
command = "manipulatePipes:serverid",
arguments = { "toPipe", params.textDocument.uri, params.position.line, params.position.character },
})
@ -27,6 +29,8 @@ return {
function()
local params = vim.lsp.util.make_position_params()
LazyVim.lsp.execute({
title = "fromPipe",
filter = "elixirls",
command = "manipulatePipes:serverid",
arguments = { "fromPipe", params.textDocument.uri, params.position.line, params.position.character },
})

View file

@ -113,7 +113,11 @@ return {
{
"<leader>cV",
function()
LazyVim.lsp.execute({ command = "typescript.selectTypeScriptVersion" })
LazyVim.lsp.execute({
title = "Select TypeScript Version",
filter = "vtsls",
command = "typescript.selectTypeScriptVersion",
})
end,
desc = "Select TS workspace version",
},

View file

@ -24,6 +24,8 @@ return {
local buf_name = vim.api.nvim_buf_get_name(0)
local file_name = vim.fn.fnamemodify(buf_name, ":t")
LazyVim.lsp.execute({
title = "Pin Main",
filter = "tinymist",
command = "tinymist.pinMain",
arguments = { buf_name },
})

View file

@ -70,9 +70,18 @@ M.action = setmetatable({}, {
---@class LspCommand: lsp.ExecuteCommandParams
---@field open? boolean
---@field handler? lsp.Handler
---@field filter? string|vim.lsp.get_clients.Filter
---@field title? string
---@param opts LspCommand
function M.execute(opts)
local filter = opts.filter or {}
filter = type(filter) == "string" and { name = filter } or filter
local buf = vim.api.nvim_get_current_buf()
---@cast filter vim.lsp.get_clients.Filter
local client = vim.lsp.get_clients(LazyVim.merge({}, filter, { bufnr = buf }))[1]
local params = {
command = opts.command,
arguments = opts.arguments,
@ -83,7 +92,8 @@ function M.execute(opts)
params = params,
})
else
return vim.lsp.buf_request(0, "workspace/executeCommand", params, opts.handler)
vim.list_extend(params, { title = opts.title })
return client:exec_cmd(params, { bufnr = buf }, opts.handler)
end
end