rename

August 11, 2026 · View on GitHub

Rename UI module for cosmic-ui. This module validates setup and module enable state, then runs rename UI logic directly. Lua API is primary; :CosmicRename is an optional wrapper.

Setup

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

⚙️ Config

rename = {
  enabled = true,
  border = {
    highlight = "FloatBorder",
    style = nil, -- falls back to vim.o.winborder
    title = "Rename",
    title_align = "left",
    title_hl = "FloatBorder",
  },
  prompt = "> ",
  prompt_hl = "Comment", -- highlight group for the prompt prefix text
}

Types

opts

Rename input options.

FieldTypeRequiredDefaultDescription
promptstring|nilNofrom config (rename.prompt)Prompt text shown in the input.
default_valuestring|nilNocurrent wordInitial value in rename input.
on_submitfunction|nilNobuilt-in rename submitCallback executed when user submits value.
windowtable|nilNointernal defaults + rename configNative float window overrides.
window.relativestring|nilNoauto (cursor position)Float anchor mode. When relative/anchor/row/col are all omitted, the prompt opens below the cursor and flips above it when there is not enough screen space below.
window.rowinteger|nilNoautoFloat row offset (disables auto flip placement when set).
window.colinteger|nilNoautoFloat column offset (disables auto flip placement when set).
window.widthinteger|nilNoauto-fit prompt + symbolFloat width.
window.heightinteger|nilNoauto-fit single prompt line (1)Float height.
window.zindexinteger|nilNo50Float z-index.
window.bordertable|nilNofrom rename border configBorder/title overrides.
window.border.stylestring|table|nilNovim.o.winborderNative border style.
window.border.titlestring|nilNofrom config (rename.border.title)Float title.
window.border.title_align"left"|"center"|"right"|nilNofrom configFloat title alignment.
window.border.highlightstring|nilNofrom configApplied to FloatBorder via winhl.
window.border.title_hlstring|nilNofrom configApplied to FloatTitle via winhl.

Module

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

Opens the rename input UI for the symbol under cursor.

Behavior:

  • warns and no-ops if setup() has not run
  • warns and no-ops if rename is disabled
  • opens rename UI when enabled
  • uses Neovim's native rename flow (vim.lsp.buf.rename) after submit
  • throws an error on invalid arguments
require("cosmic-ui").rename.open()
require("cosmic-ui").rename.open({
  default_value = "new_symbol_name",
  window = {
    width = 40,
    border = { title = "Rename Symbol" },
  },
})

Optional command:

  • :CosmicRename opens the Cosmic rename prompt.