23 lines
598 B
Lua
23 lines
598 B
Lua
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"
|
|
})
|