A blueprint/template/guide to customize Neovim's UI using Lua.
This is a simple customisable UI plugin written in Lua for you to play around with!
If you ever worked on modifying Neovim's UI, it might feel frustrating to work with. The docs(as of 0.11
) don't go too deep into it either(as this is still experimental). This repository is meant to change that.
You no longer need to write boilerplate
or handle errors without using messages or spend hours trying to figure put how to handle different Ui events. As this is also usable as a plugin, you don't have to worry about things being outdated either!
As of now, this plugin comes with the following things,
heads up
for various quirky scenarios.A bunch of helpers are also provided,
ui/highlights.lua
). This automatically makes the plugin supported by almost all colorschemes.virtual text
& UI contents
into a buffer as actual text with highlights!virtual text
into statuscolumn content. This makes adding complex signs on wrapped lines much easier!functions
as configuration options without using conditionals
everywhere.I recommend reading :h ui.txt
first(don't worry if you don't understand it).
[!TIP] The wiki is also available in vimdoc(see
:h ui.nvim
)!
You can check the wiki for the explanations and read the source files for the actual implementation.
[!NOTE] If you want to help, feel free to point out issues with the wiki!
Custom UI for the command-line. It supports,
:lua
, :=
, :!
etc.).Custom UI for the message. It supports,
confirmation
and list
style messages.:messages
window with support for multiple message providers(vim
& internal
).showcmd
support.Custom UI for the pop-up menu. It supports,
Dynamic highlight groups.
Pum menu giving incorrect position & size in completion events.
Breaks: mini.completion
Going into command mode
after a write causes duplicate message with wrong kind.
Breaks: nvim-0.11
[!WARNING] Do not lazy load this plugin! It is supposed to be loaded before other plugins(right after loading your
colorscheme
).
For plugins.lua
users,
{
"OXY2DEV/ui.nvim",
lazy = false
};
For plugins/ui.lua
users,
return {
"OXY2DEV/ui.nvim",
lazy = false
};
local MiniDeps = require("mini.deps");
MiniDeps.add({
source = "OXY2DEV/ui.nvim"
});
[!WARNING]
luarocks package
may sometimes be a bit behindmain
.
:Rocks install ui.nvim
The plugin can be configured via the setup()
function. You can check the default configuration table here.
A simplified version of the configuration table is given below,
require("ui").setup({
popupmenu = {
enable = true,
winconfig = {},
tooltip = nil,
styles = {
default = {
padding_left = " ",
padding_right = " ",
icon = nil,
text = nil,
normal_hl = nil,
select_hl = "CursorLine",
icon_hl = nil
},
example = {
condition = function ()
return true;
end,
icon = "I "
}
}
},
cmdline = {
enable = true,
styles = {
default = {
cursor = "Cursor",
filetype = "vim",
icon = { { "I ", "@comment" } },
offset = 0,
title = nil,
winhl = ""
},
example = {
condition = function ()
return true;
end,
cursor = "@comment"
}
}
},
message = {
enable = true,
message_winconfig = {},
list_winconfig = {},
confirm_winconfig = {},
history_winconfig = {},
ignore = function ()
return false:
end,
showcmd = {
max_width = 10,
modifier = nil
},
msg_styles = {
default = {
duration = 500,
modifier = nil,
decorations = {
icon = { { "I " } }
}
},
example = {
condition = function ()
return true;
end,
decorations = {
icon = { { "B " } }
}
}
},
is_list = function ()
return false;
end,
list_styles = {
default = {
modifier = nil,
row = nil,
col = nil,
width = nil,
height = nil,
winhl = nil
},
example = {
condition = function ()
return true;
end,
border = "rounded"
}
},
confirm_styles = {
default = {
modifier = nil,
row = nil,
col = nil,
width = nil,
height = nil,
winhl = nil
},
example = {
condition = function ()
return true;
end,
border = "rounded"
}
}
}
});
[!TIP] You can call the
setup()
as many times as you want!
You can run :UI
to toggle the custom UI. It has the following sub-commands,
enable
Enables custom UI.
disable
Disables custom UI.
toggle
Toggles custom UI.
By default this plugin comes with the following highlight groups,
UICmdlineDefault
UICmdlineDefaultIcon
UICmdlineLua
UICmdlineLuaIcon
UICmdlineEval
UICmdlineEvalIcon
UICmdlineSearchUp
UICmdlineSearchUpIcon
UICmdlineSearchDown
UICmdlineSearchDownIcon
UICmdlineSubstitute
UICmdlineSubstituteIcon
UIMessageDefault
UIMessageOk
UIMessageInfo
UIMessageInfoSign
UIMessageWarn
UIMessageWarnSign
UIMessageError
UIMessageErrorSign
UIMessagePalette
UIMessageErrorSign
UIHistoryKeymap
UIHistoryDesc
UIMenuSelect
UIMenuKeymap