Documentation
Prompt

Prompt

Prompt is a custom single-line TextInput component that includes a prefix and an on_submit callback.

Usage Example

n.prompt({
  prefix = " > ",
  placeholder = "Enter a command",
  border_label = {
    text = "Command",
    align = "center",
  },
  on_submit = function(value)
    print(value)
  end,
})

Properties

value

Type
string

prefix

Type
string

placeholder

Optional placeholder text to show when the input is empty. Can be a string, a single virtual text chunk, or a list of virtual text chunks.

Default value
nil
Type
string | { [1]: string, [2]: string }[] | nil

A virtual text chunk is a tuple-like table where the first element is the text and the second element is the highlight group.

local placeholder = {
  { "Hello", "Comment" },
  { "World", "String" },
}

on_change

Type
fun(value: string, component: Prompt): nil

on_submit

Type
fun(value: string, component: Prompt): nil

submit_key

Default value
<CR>
Type
string[] | string

Hightlight Groups

  • NuiComponentsPromptPrefix