Add code action for organizing imports in python.
This commit is contained in:
parent
9da90d53fa
commit
4d6fff0bf2
|
@ -0,0 +1,22 @@
|
|||
local organize_imports = function()
|
||||
local cur_buf = vim.api.nvim_get_current_buf()
|
||||
local cur_buf_name = vim.api.nvim_buf_get_name(cur_buf)
|
||||
local params = { command = "source.organizeImports.ruff", arguments = { cur_buf_name } }
|
||||
vim.lsp.buf_request_sync(cur_buf, 'textDocument/codeAction', params)
|
||||
end
|
||||
|
||||
|
||||
require("which-key").add({
|
||||
"<leader>co",
|
||||
function()
|
||||
vim.lsp.buf.code_action({
|
||||
apply = true,
|
||||
context = {
|
||||
only = { "source.organizeImports" }, -- Or the specific ruff identifier if known
|
||||
},
|
||||
bufnr = vim.api.nvim_get_current_buf(),
|
||||
})
|
||||
end
|
||||
,
|
||||
name = "Organize Imports"
|
||||
})
|
Loading…
Reference in New Issue