vim.lsp.buf.execute_command is deprececated in favor of clint:exec_cmd
The vim.lsp.buf.execute_command is used to execute a command on the LSP server for a specific buffer.
Neovim will deprecate (see :checkhealt vim.deprecated) vim.lsp.buf.execute_command in favor of clint:exec_cmd in the future. For example to the typescript organizeImport should be changed from:
local function on_ts_ls_attach(client, bufnr)
vim.keymap.set("n", "<leader>o",
"<cmd>lua vim.lsp.buf.execute_command({command = \"_typescript.organizeImports\", arguments = {vim.fn.expand(\"%:p\")}})<cr>",
{ noremap = true, silent = true, buffer = bufnr })
end
to
local function on_ts_ls_attach(client, bufnr)
vim.keymap.set("n", "<leader>o", function
return client:exec_cmd({
command = "_typescript.organizeImports",
arguments = { vim.api.nvim_buf_get_name(bufnr) }
}, { bufnr = bufnr })
end, { noremap = true, silent = true, buffer = bufnr })
end
If also think that the new format is more readable and more flexible.
Ajnasz Blog lets readers post comments anonymously or by signing in with Google, GitHub, or Telegram.
comments loading...