Provide support for workspace/executeCommand
LSP capability
#5301
Closed
pmanole-volvocars
started this conversation in
Ideas
Replies: 1 comment
-
UPDATE: Got what I wanted working: organize_imports_biome = {
cond = function(client) return client.name == "biome" end,
{
event = { "BufWritePost" }, -- has to be post, otherwise doesn't work
callback = function()
local clients = vim.lsp.get_clients { bufnr = 0 }
for _, client in pairs(clients) do
if client.name == "biome" then
if client.server_capabilities.codeActionProvider then
local actions_supported = client.server_capabilities.codeActionProvider
if actions_supported and actions_supported.codeActionKinds then
-- Now check if organizeImports is in the supported actions
local can_organize_imports = false
for _, action in ipairs(actions_supported.codeActionKinds) do
if action == "source.organizeImports.biome" then
can_organize_imports = true
break
end
end
if can_organize_imports then
---@diagnostic disable-next-line: assign-type-mismatch
vim.lsp.buf.code_action { context = { only = { "source.organizeImports.biome" } }, apply = true }
end
end
end
end
end
end,
},
}, But it's so much code. I think the discussion can be closed though. 🐰 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Please consider providing support for the
workspace/executeCommand
LSP capability.It should make it easier for editors like NeoVim to create on-save actions, such as running the
source.organizeImports
command.textDocument/codeAction
requires too many arguments and I still could not get it to work. The command seems to do nothing (see comments below).I'm using AstroNvim, with AstroLSP plugin configured with this autocmd:
Beta Was this translation helpful? Give feedback.
All reactions