Configuration - OXY2DEV/ui.nvim GitHub Wiki
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
}
});
Used by the command-line. It has the following structure,
---@type ui.config.cmdline
cmdline = {
enable = true,
row_offset = 1,
styles = {
default = {}
}
}
- Type:
boolean
- Default:
true
Whether to use the custom command-line.
- 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!
- 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
.
- 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 = {}
}
- Type:
string
Highlight group for the special character
shown under cursor(see <CTRL-v>
).
- Type:
string
File type of the command-line.
- Type:
[ string, string? ][]
Icon for the command-line. Has the same structure as virtual text
.
- Type:
integer
Character offset. The number of characters to hide from the start.
Used for :!
, :=
, :lua
etc.
- Type:
( [ string, string? ][] )[]
Title to show above the command-line. Has the same structure as virtual lines
.
- Type:
string
Value of the winhl
option for the command-line window.
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
}
}
- Type:
boolean
- Default:
true
Whether to use custom messages.
- 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!
- 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!
- 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!
- 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.
- 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.
- Type:
table
Configuration table for the history window. Has the same options as {opts}
in nvim_open_win()
.
- Type:
table
Configuration table for the message window. Has the same options as {opts}
in nvim_open_win()
.
- Type:
table
Configuration table for the list message window. Has the same options as {opts}
in nvim_open_win()
.
- Type:
table
Configuration table for the confirmation message window. Has the same options as {opts}
in nvim_open_win()
.
- Type:
table
Configuration table for the showcmd
message window. Has the same options as {opts}
in nvim_open_win()
.
- 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.
- 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!
- 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 = ""
}
- Type:
fun(msg: ui.message.entry, lines: string[], extmarks: ui.message.hl_fragment[][]): boolean
Condition for this style.
- Type:
"single" | "rounded" | "double" | "solid" | "shadow" | string[] | [ string string? ][]
Window border.
- Type:
integer
Column position of the confirmation window.
- Type:
integer
Height of the confirmation window.
- 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.
- Type:
integer
Row position of the confirmation window.
- Type:
integer
Width of the confirmation window.
- Type:
string
Value of the winhl
option for the confirmation window.
- Type:
table<string, ui.message.confirm>
Changes how different list messages are shown. It has the same structure as confirm_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
}
- Type:
fun(msg: ui.message.entry, lines: string[], extmarks: ui.message.hl_fragment[][]): boolean
Condition for this style.
- 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"
}
- Type:
[ string, string? ][]
Icon for this message. The structure is the same as virtual text
.
- Type:
[ string, string? ][]
Replaces icon
for lines that are not the first line of the message.
- Type:
[ string, string? ][]
Replaces icon
for the last line of the message.
- Type:
string
Line highlight group for the message.
- Type:
ui.message.decorations
Same as decorations
, but it will only be shown on the history window.
- Type:
integer
The number of milliseconds the message should be visible for.
- 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.
Used by the pop-up menu. It has the following structure,
popupmenu = {
enable = true,
entries = {
default = {}
},
winconfig = {},
max_height = 5,
tooltip = nil
}
- Type:
boolean
- Default:
true
Whether to use the custom pop-up menu.
- 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"
}
- 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 "").
- Type:
string
- Type:
string
- Type:
string
- Type:
string
Text to show instead of the actual completion.
- Type:
string
Highlight group for the candidate.
- Type:
string
Highlight group for the candidate when selected.
- Type:
string
Highlight group for the icon.
- Type:
table
Window configuration for the pop-up menu.
- Type:
integer
Maximum height of the menu(when the menu is shown under cursor).
- Type:
[ string, string? ][]
Allows adding some tooltip to the menu(the window must have a border for it to work outside of command mode).
Configuration options for the showcmd messages. It has the following structure,
showcmd = {
max_width = math.floor(vim.o.columns * 0.5),
modifier = nil
}
- Type:
integer
Maximum width of the showcmd window.
- 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.