Configuration - OXY2DEV/ui.nvim GitHub Wiki

🔩 Configuration

This plugin can be configured via the setup() function. You can check the default configuration here.

Tip

You can find the type definitions for the options here.

require("ui").setup({
    cmdline = {
        enable = true
    },

    messages = {
        enable = true
    },

    popupmenu = {
        enable = true
    }
});

🔩 Cmdline options

Used by the command-line. It has the following structure,

---@type ui.config.cmdline
cmdline = {
    enable = true,
    row_offset = 1,

    styles = {
        default = {}
    }
}

enable

  • Type: boolean
  • Default: true

Whether to use the custom command-line.

row_offset

  • Type: integer
  • Default: 1

Number of rows the command-line should be from the bottom of the screen.

Tip

This can be set to 0 to mimic Vim's command-line when cmdheight=0.

Command-line window position is calculated with the following formula.

row = total_lines - (cmdheight + estimated_window_height + row_offset)

This also affects where the message window is shown!

styles

  • Type: table<string, ui.cmdline.style>

Styles for the command-line.

You can set the default style using the default key. Each style has the following structure,

example = {
    condition = function ()
        return true;
    end,

    cursor = "Cursor",
    filetype = "vim",
    icon = nil,

    offset = 0,
    title = {
        {
            { "Some title: ", "Comment" }
        }
    },

    winhl = ""
}

Note

All the options mentioned below can be functions too and they will receive the same parameters as condition.

The value of the matched style will get automatically merged with the other styles when they are used, so you don't need to define the same style everywhere. For example, if a style doesn't have winhl the value of winhl will be taken from default.

condition

  • Type: function (state: ui.cmdline.state, lines: string[]): boolean

Condition for the style. state is the command-line state and lines is the lines shown in the command-line window.

The state looks something like this,

All the parameters given to the command-line are shown here. The key is the parameter name in :h ui-cmdline.

{
    firstc = ":",
    level = 1,

    prompt = nil,
    lines = {}
}

cursor

  • Type: string

Highlight group for the special character shown under cursor(see <CTRL-v>).

filetype

  • Type: string

File type of the command-line.

icon

  • Type: [ string, string? ][]

Icon for the command-line. Has the same structure as virtual text.

offset

  • Type: integer

Character offset. The number of characters to hide from the start.

Used for :!, :=, :lua etc.

title

  • Type: ( [ string, string? ][] )[]

Title to show above the command-line. Has the same structure as virtual lines.

winhl

  • Type: string

Value of the winhl option for the command-line window.

🔩 Message options

Used by the messages. It has the following structure,

---@type ui.config.message
message = {
    enable = true,
    wrap_notify = true,
    respect_replace_last = true,

    history_preference = "vim",
    max_lines = nil,
    max_duration = 5000,

    history_winconfig = {},
    message_winconfig = {},
    list_winconfig = {},
    confirm_winconfig = {},
    showcmd_winconfig = {},

    is_list = function ()
        return false;
    end,
    ignore = function ()
        return false;
    end,

    confirm_styles = {
        default = {}
    },
    list_styles = {
        default = {}
    },
    msg_styles = {
        default = {}
    },

    showcmd = {
        max_width = 20,
        modifier = function ()
            return {};
        end
    }
}

enable

  • Type: boolean
  • Default: true

Whether to use custom messages.

wrap_notify

  • Type: boolean
  • Default: true

When true, vim.notify & vim.notify_once are replaced with the plugin's own message functions.

This is used to disable replace_last for these functions!

respect_replace_last

  • Type: boolean
  • Default: true

When set to false, every, yes every, message will be be shown as individual message.

Note

This may cause performance issues if messages are spammed!

history_preference

  • Type: "vim" | "internal"
  • Default: "vim"

Default history source preference for the message history. It has the following supported values,

  • "vim", use the history provided by Neovim.
  • "internal", use the plugin's internal message history.

Some messages aren't shown in the history by Neovim, in those cases you might want to use the plugin's own history source which contains most messages(excluding list & confirm messages).

Tip

You can press t while inside the history window to toggle the source!

max_lines

  • Type: integer

Maximum number of lines a message can have before being shown in the list window.

When nil, any message longer then 1/2 of the total screen height is shown in the list window.

max_duration

  • Type: integer
  • Default: 5000

Number of milliseconds a message can stay at most. Useful if you don't like long messages on the screen for too long.

history_winconfig

  • Type: table

Configuration table for the history window. Has the same options as {opts} in nvim_open_win().

message_winconfig

  • Type: table

Configuration table for the message window. Has the same options as {opts} in nvim_open_win().

list_winconfig

  • Type: table

Configuration table for the list message window. Has the same options as {opts} in nvim_open_win().

confirm_winconfig

  • Type: table

Configuration table for the confirmation message window. Has the same options as {opts} in nvim_open_win().

showcmd_winconfig

  • Type: table

Configuration table for the showcmd message window. Has the same options as {opts} in nvim_open_win().

is_list

  • Type: fun(kind: ui.message.kind, content: ui.messages.fragment[], add_to_history: boolean): boolean

Function to determine whether a message should be treated like a list or not.

Note

Some messages are considered lists(e.g. :set), even if they only have a single line. You can use these to filter those message out.

ignore

  • Type: fun(kind: ui.message.kind, content: ui.messages.fragment[]): boolean

Function to determine whether a message should be ignored or not.

Tip

You can use this to reduce visual clutters!

confirm_styles

  • Type: table<string, ui.message.confirm>

Changes how different confirmation messages are shown. Each style has the following structure,

example = {
    condition = function ()
        return true;
    end,

    border = "rounded",
    col = 0,
    height = 1,

    modifier = function ()
        return {
            lines = {},
            extmarks = {}
        };
    end,

    row = 0,
    width = 10,

    winhl = ""
}

condition

  • Type: fun(msg: ui.message.entry, lines: string[], extmarks: ui.message.hl_fragment[][]): boolean

Condition for this style.

border

  • Type: "single" | "rounded" | "double" | "solid" | "shadow" | string[] | [ string string? ][]

Window border.

col

  • Type: integer

Column position of the confirmation window.

height

  • Type: integer

Height of the confirmation window.

modifier

  • Type: fun(msg: ui.message.entry, lines: string[], extmarks: ui.message.hl_fragment[][]): { lines: string[], extmarks: ui.message.hl_fragment[][] }

Used to modify the contents of the message.

row

  • Type: integer

Row position of the confirmation window.

width

  • Type: integer

Width of the confirmation window.

winhl

  • Type: string

Value of the winhl option for the confirmation window.

list_styles

  • Type: table<string, ui.message.confirm>

Changes how different list messages are shown. It has the same structure as confirm_styles.

msg_styles

  • Type: table<string, ui.message.style>

Changes how messages are shown. Each style has the following structure,

example = {
    condition = function ()
        return true;
    end,

    decorations = {},
    history_decorations = {},

    duration = 5000,
    modifier = function ()
        return {
            lines = {},
            extmarks = {}
        };
    end
}

condition

  • Type: fun(msg: ui.message.entry, lines: string[], extmarks: ui.message.hl_fragment[][]): boolean

Condition for this style.

decorations

  • Type: ui.message.decorations

Decorations for the message. It has the following structure,

decorations = {
    icon = {
        { "X ", "Comment" }
    },
    padding = nil,
    tail = nil,

    line_hl_group = "CursorLine"
}
icon
  • Type: [ string, string? ][]

Icon for this message. The structure is the same as virtual text.

padding
  • Type: [ string, string? ][]

Replaces icon for lines that are not the first line of the message.

tail
  • Type: [ string, string? ][]

Replaces icon for the last line of the message.

line_hl_group
  • Type: string

Line highlight group for the message.

history_decorations

  • Type: ui.message.decorations

Same as decorations, but it will only be shown on the history window.

duration

  • Type: integer

The number of milliseconds the message should be visible for.

modifier

  • Type: fun(msg: ui.message.entry, lines: string[], extmarks: ui.message.hl_fragment[][]): { lines: string[], extmarks: ui.message.hl_fragment[][] }

Used to modify the contents of the message.

🔩 Popupmenu options

Used by the pop-up menu. It has the following structure,

popupmenu = {
    enable = true,

    entries = {
        default = {}
    },

    winconfig = {},
    max_height = 5,

    tooltip = nil
}

enable

  • Type: boolean
  • Default: true

Whether to use the custom pop-up menu.

entries

  • Type: table<string, ui.popupmenu.style>

Configuration for each entry in pop-up menu. Each entry has the following structure,

example = {
    condition = function ()
        return true;
    end,

    padding_left = " ",
    padding_right = " ",

    icon = " ",
    text = nil,

    normal_hl = nil,
    select_hl = "CursorLine",
    icon_hl = "Special"
}

condition

  • Type: function (word: string, kind: ui.popupmenu.kind, menu: string, info: string): boolean

Condition for the style word is the completion, kind is the type of completion, menu is the extra text for the pop-up menu(for now this is always ""), info is the extra information to show(for now this is always "").

padding_left

  • Type: string

padding_right

  • Type: string

icon

  • Type: string

text

  • Type: string

Text to show instead of the actual completion.

normal_hl

  • Type: string

Highlight group for the candidate.

select_hl

  • Type: string

Highlight group for the candidate when selected.

icon_hl

  • Type: string

Highlight group for the icon.

winconfig

  • Type: table

Window configuration for the pop-up menu.

max_height

  • Type: integer

Maximum height of the menu(when the menu is shown under cursor).

tooltip

  • Type: [ string, string? ][]

Allows adding some tooltip to the menu(the window must have a border for it to work outside of command mode).

showcmd

Configuration options for the showcmd messages. It has the following structure,

showcmd = {
	max_width = math.floor(vim.o.columns * 0.5),

    modifier = nil
}

max_width

  • Type: integer

Maximum width of the showcmd window.

modifier

  • Type: fun(msg: ui.message.fragment[], lines: string[], extmarks: ui.message.hl_fragment[][]): { lines: string[], extmarks: ui.message.hl_fragment[][] }

Modifier for the showcmd message.

⚠️ **GitHub.com Fallback** ⚠️