Skip to content

Latest commit

 

History

History
98 lines (76 loc) · 2.55 KB

File metadata and controls

98 lines (76 loc) · 2.55 KB

codeactions

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.

Setup

require("cosmic-ui").setup({
  codeactions = {
    enabled = true,
  },
})

⚙️ Config

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",
  },
}

Types

opts

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}.

Module

require("cosmic-ui").codeactions.open(opts?)

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 codeactions is disabled
  • executes code action requests via the internal cosmic-ui.codeactions implementation
  • 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" } } },
})

require("cosmic-ui").codeactions.range(opts?)

Requests code actions for the active visual selection.

Behavior:

  • uses opts.range when provided
  • else uses opts.params when 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:

  • :CosmicCodeActions opens the Cosmic code action panel.