Code actions module for cosmic-ui.
This module validates setup/module enable state and runs code action requests directly.
Lua API is primary; :CosmicCodeActions is an optional wrapper.
require("cosmic-ui").setup({
codeactions = {
enabled = true,
},
})codeactions = {
enabled = true,
min_width = nil,
border = {
bottom_hl = "FloatBorder",
highlight = "FloatBorder",
style = nil, -- falls back to vim.o.winborder
title = "Code Actions",
title_align = "center",
title_hl = "FloatBorder",
},
}Optional request options passed to the code action core module.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
params |
table|nil |
No | nil |
Explicit LSP request params. |
range |
table|nil |
No | nil |
Optional range { start, end }. |
range.start |
{integer, integer}|nil |
No | nil |
Optional start position {line, col}. |
range.end |
{integer, integer}|nil |
No | nil |
Optional end position {line, col}. |
Requests and opens code actions at the current cursor context.
Behavior:
- warns and no-ops if
setup()has not run - warns and no-ops if
codeactionsis disabled - executes code action requests via the internal
cosmic-ui.codeactionsimplementation - opens a native floating menu (no NUI dependency)
- menu groups are ordered deterministically by client name (tie-break: client id)
- actions within each client group keep server response order
- group headers are rendered as plain section rows
- selection index/count is shown in the float border footer (right-aligned)
- keymaps:
j/k,<Down>/<Up>,<Tab>/<S-Tab>,<CR>/<Space>,<Esc>/<C-c>
require("cosmic-ui").codeactions.open()require("cosmic-ui").codeactions.open({
params = { context = { only = { "quickfix" } } },
})Requests code actions for the active visual selection.
Behavior:
- uses
opts.rangewhen provided - else uses
opts.paramswhen provided - else builds range from visual marks
'<and'> - warns and no-ops if
setup()has not run or module is disabled
vim.keymap.set("v", "<leader>ga", function()
require("cosmic-ui").codeactions.range()
end)require("cosmic-ui").codeactions.range({
range = { start = { 10, 0 }, ["end"] = { 12, 0 } },
})Optional command:
:CosmicCodeActionsopens the Cosmic code action panel.