mirror of https://github.com/folke/lazy.nvim.git
feat(ui): made all highlight groups and icons configurable
This commit is contained in:
parent
3d22c496da
commit
0ea771bd70
47
README.md
47
README.md
|
@ -315,6 +315,8 @@ return {
|
|||
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
|
||||
border = "none",
|
||||
icons = {
|
||||
loaded = "●",
|
||||
not_loaded = "○",
|
||||
cmd = " ",
|
||||
config = "",
|
||||
event = "",
|
||||
|
@ -327,6 +329,12 @@ return {
|
|||
start = "",
|
||||
task = "✔ ",
|
||||
lazy = "鈴 ",
|
||||
list = {
|
||||
"●",
|
||||
"➜",
|
||||
"★",
|
||||
"‒",
|
||||
},
|
||||
},
|
||||
throttle = 20, -- how frequently should the ui process render events
|
||||
custom_keys = {
|
||||
|
@ -667,28 +675,35 @@ To uninstall **lazy.nvim**, you need to remove the following files and directori
|
|||
<!-- colors:start -->
|
||||
|
||||
| Highlight Group | Default Group | Description |
|
||||
| ---------------------- | -------------------------- | ----------------- |
|
||||
| --------------------- | -------------------------- | --------------------------------------------------- |
|
||||
| **LazyButton** | **_CursorLine_** | |
|
||||
| **LazyButtonActive** | **_Visual_** | |
|
||||
| **LazyCommit** | **_@variable.builtin_** | |
|
||||
| **LazyError** | **_ErrorMsg_** | task errors |
|
||||
| **LazyH1** | **_IncSearch_** | |
|
||||
| **LazyH2** | **_Bold_** | |
|
||||
| **LazyHandlerCmd** | **_Operator_** | |
|
||||
| **LazyHandlerEvent** | **_Constant_** | |
|
||||
| **LazyHandlerFt** | **_Character_** | |
|
||||
| **LazyHandlerKeys** | **_Statement_** | |
|
||||
| **LazyHandlerPlugin** | **_Special_** | |
|
||||
| **LazyHandlerRuntime** | **_@macro_** | |
|
||||
| **LazyHandlerSource** | **_Character_** | |
|
||||
| **LazyHandlerStart** | **_@field_** | |
|
||||
| **LazyKey** | **_Conceal_** | |
|
||||
| **LazyMuted** | **_Comment_** | |
|
||||
| **LazyComment** | **_Comment_** | |
|
||||
| **LazyCommit** | **_@variable.builtin_** | commit ref |
|
||||
| **LazyCommitIssue** | **_Number_** | |
|
||||
| **LazyCommitScope** | **_Italic_** | conventional commit scope |
|
||||
| **LazyCommitType** | **_Title_** | conventional commit type |
|
||||
| **LazyDir** | **_@text.reference_** | directory |
|
||||
| **LazyH1** | **_IncSearch_** | home button |
|
||||
| **LazyH2** | **_Bold_** | titles |
|
||||
| **LazyNoCond** | **_DiagnosticWarn_** | unloaded icon for a plugin where `cond()` was false |
|
||||
| **LazyNormal** | **_NormalFloat_** | |
|
||||
| **LazyProgressDone** | **_Constant_** | progress bar done |
|
||||
| **LazyProgressTodo** | **_LineNr_** | progress bar todo |
|
||||
| **LazyProp** | **_Conceal_** | property |
|
||||
| **LazyReasonCmd** | **_Operator_** | |
|
||||
| **LazyReasonEvent** | **_Constant_** | |
|
||||
| **LazyReasonFt** | **_Character_** | |
|
||||
| **LazyReasonKeys** | **_Statement_** | |
|
||||
| **LazyReasonPlugin** | **_Special_** | |
|
||||
| **LazyReasonRuntime** | **_@macro_** | |
|
||||
| **LazyReasonSource** | **_Character_** | |
|
||||
| **LazyReasonStart** | **_@field_** | |
|
||||
| **LazySpecial** | **_@punctuation.special_** | |
|
||||
| **LazyValue** | **_@string_** | |
|
||||
| **LazyTaskError** | **_ErrorMsg_** | task errors |
|
||||
| **LazyTaskOutput** | **_MsgArea_** | task output |
|
||||
| **LazyUrl** | **_@text.reference_** | url |
|
||||
| **LazyValue** | **_@string_** | value of a property |
|
||||
|
||||
<!-- colors:end -->
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ M.defaults = {
|
|||
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
|
||||
border = "none",
|
||||
icons = {
|
||||
loaded = "●",
|
||||
not_loaded = "○",
|
||||
cmd = " ",
|
||||
config = "",
|
||||
event = "",
|
||||
|
@ -49,6 +51,12 @@ M.defaults = {
|
|||
start = "",
|
||||
task = "✔ ",
|
||||
lazy = "鈴 ",
|
||||
list = {
|
||||
"●",
|
||||
"➜",
|
||||
"★",
|
||||
"‒",
|
||||
},
|
||||
},
|
||||
throttle = 20, -- how frequently should the ui process render events
|
||||
custom_keys = {
|
||||
|
|
|
@ -1,28 +1,34 @@
|
|||
local M = {}
|
||||
|
||||
M.colors = {
|
||||
Error = "ErrorMsg", -- task errors
|
||||
H1 = "IncSearch",
|
||||
H2 = "Bold",
|
||||
Muted = "Comment",
|
||||
H1 = "IncSearch", -- home button
|
||||
H2 = "Bold", -- titles
|
||||
Comment = "Comment",
|
||||
Normal = "NormalFloat",
|
||||
Commit = "@variable.builtin",
|
||||
Key = "Conceal",
|
||||
Value = "@string",
|
||||
NoCond = "DiagnosticError",
|
||||
Commit = "@variable.builtin", -- commit ref
|
||||
CommitIssue = "Number",
|
||||
CommitType = "Title", -- conventional commit type
|
||||
CommitScope = "Italic", -- conventional commit scope
|
||||
Prop = "Conceal", -- property
|
||||
Value = "@string", -- value of a property
|
||||
NoCond = "DiagnosticWarn", -- unloaded icon for a plugin where `cond()` was false
|
||||
ProgressDone = "Constant", -- progress bar done
|
||||
ProgressTodo = "LineNr", -- progress bar todo
|
||||
Special = "@punctuation.special",
|
||||
HandlerRuntime = "@macro",
|
||||
HandlerPlugin = "Special",
|
||||
HandlerEvent = "Constant",
|
||||
HandlerKeys = "Statement",
|
||||
HandlerStart = "@field",
|
||||
HandlerSource = "Character",
|
||||
HandlerFt = "Character",
|
||||
HandlerCmd = "Operator",
|
||||
ReasonRuntime = "@macro",
|
||||
ReasonPlugin = "Special",
|
||||
ReasonEvent = "Constant",
|
||||
ReasonKeys = "Statement",
|
||||
ReasonStart = "@field",
|
||||
ReasonSource = "Character",
|
||||
ReasonFt = "Character",
|
||||
ReasonCmd = "Operator",
|
||||
Button = "CursorLine",
|
||||
ButtonActive = "Visual",
|
||||
TaskOutput = "MsgArea", -- task output
|
||||
TaskError = "ErrorMsg", -- task errors
|
||||
Dir = "@text.reference", -- directory
|
||||
Url = "@text.reference", -- url
|
||||
}
|
||||
|
||||
M.did_setup = false
|
||||
|
|
|
@ -77,6 +77,10 @@ function M:mount()
|
|||
end
|
||||
|
||||
---@class LazyViewWinOpts
|
||||
---@field width number
|
||||
---@field height number
|
||||
---@field row number
|
||||
---@field col number
|
||||
local win_opts = {
|
||||
relative = "editor",
|
||||
style = "minimal",
|
||||
|
@ -111,6 +115,7 @@ function M:mount()
|
|||
self:layout()
|
||||
local config = {}
|
||||
for _, key in ipairs({ "relative", "width", "height", "col", "row" }) do
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
config[key] = self.opts.win_opts[key]
|
||||
end
|
||||
vim.api.nvim_win_set_config(self.win, config)
|
||||
|
|
|
@ -141,10 +141,10 @@ function M:title()
|
|||
if self.view.state.mode ~= "help" and self.view.state.mode ~= "profile" and self.view.state.mode ~= "debug" then
|
||||
if self.progress.done < self.progress.total then
|
||||
self:append("Tasks: ", "LazyH2")
|
||||
self:append(self.progress.done .. "/" .. self.progress.total, "LazyMuted")
|
||||
self:append(self.progress.done .. "/" .. self.progress.total, "LazyComment")
|
||||
else
|
||||
self:append("Total: ", "LazyH2")
|
||||
self:append(#self.plugins .. " plugins", "LazyMuted")
|
||||
self:append(#self.plugins .. " plugins", "LazyComment")
|
||||
end
|
||||
self:nl():nl()
|
||||
end
|
||||
|
@ -174,7 +174,7 @@ function M:help()
|
|||
self:append("- ", "LazySpecial", { indent = 2 })
|
||||
self:append(title, "Title")
|
||||
if mode.key then
|
||||
self:append(" <" .. mode.key .. ">", "LazyKey")
|
||||
self:append(" <" .. mode.key .. ">", "LazyProp")
|
||||
end
|
||||
self:append(" " .. (mode.desc or "")):nl()
|
||||
end
|
||||
|
@ -187,7 +187,7 @@ function M:help()
|
|||
self:append("- ", "LazySpecial", { indent = 2 })
|
||||
self:append(title, "Title")
|
||||
if mode.key_plugin then
|
||||
self:append(" <" .. mode.key_plugin .. ">", "LazyKey")
|
||||
self:append(" <" .. mode.key_plugin .. ">", "LazyProp")
|
||||
end
|
||||
self:append(" " .. (mode.desc_plugin or mode.desc)):nl()
|
||||
end
|
||||
|
@ -225,7 +225,7 @@ function M:section(section)
|
|||
|
||||
local count = #section_plugins
|
||||
if count > 0 then
|
||||
self:append(section.title, "LazyH2"):append(" (" .. count .. ")", "LazyMuted"):nl()
|
||||
self:append(section.title, "LazyH2"):append(" (" .. count .. ")", "LazyComment"):nl()
|
||||
for _, plugin in ipairs(section_plugins) do
|
||||
self:plugin(plugin)
|
||||
end
|
||||
|
@ -306,13 +306,13 @@ function M:reason(reason, opts)
|
|||
if key == "keys" then
|
||||
value = type(value) == "string" and value or value[1]
|
||||
end
|
||||
local hl = "LazyHandler" .. key:sub(1, 1):upper() .. key:sub(2)
|
||||
local hl = "LazyReason" .. key:sub(1, 1):upper() .. key:sub(2)
|
||||
local icon = Config.options.ui.icons[key]
|
||||
if icon then
|
||||
self:append(icon .. " ", hl)
|
||||
self:append(value, hl)
|
||||
else
|
||||
self:append(key .. " ", "@field")
|
||||
self:append(key .. " ", hl)
|
||||
self:append(value, hl)
|
||||
end
|
||||
end
|
||||
|
@ -320,7 +320,6 @@ function M:reason(reason, opts)
|
|||
if time and opts.time_right then
|
||||
self:append(time, "Bold")
|
||||
end
|
||||
-- self:append(")", "Conceal")
|
||||
end
|
||||
|
||||
---@param plugin LazyPlugin
|
||||
|
@ -358,11 +357,11 @@ end
|
|||
---@param plugin LazyPlugin
|
||||
function M:plugin(plugin)
|
||||
if plugin._.loaded then
|
||||
self:append(" ● ", "LazySpecial"):append(plugin.name)
|
||||
self:append(" " .. Config.options.ui.icons.loaded .. " ", "LazySpecial"):append(plugin.name)
|
||||
elseif plugin._.cond == false then
|
||||
self:append(" ○ ", "LazyNoCond"):append(plugin.name)
|
||||
self:append(" " .. Config.options.ui.icons.not_loaded .. " ", "LazyNoCond"):append(plugin.name)
|
||||
else
|
||||
self:append(" ○ ", "LazySpecial"):append(plugin.name)
|
||||
self:append(" " .. Config.options.ui.icons.not_loaded .. " ", "LazySpecial"):append(plugin.name)
|
||||
end
|
||||
local plugin_start = self:row()
|
||||
if plugin._.loaded then
|
||||
|
@ -382,25 +381,22 @@ end
|
|||
---@param plugin LazyPlugin
|
||||
function M:tasks(plugin)
|
||||
for _, task in ipairs(plugin._.tasks or {}) do
|
||||
if self.view.state.plugin == plugin.name then
|
||||
self:append("✔ [task] ", "Title", { indent = 4 }):append(task.name)
|
||||
if self.view:is_selected(plugin) then
|
||||
self:append(Config.options.ui.icons.task .. "[task] ", "Title", { indent = 4 }):append(task.name)
|
||||
self:append(" " .. math.floor((task:time()) * 100) / 100 .. "ms", "Bold")
|
||||
self:nl()
|
||||
end
|
||||
if task.name == "log" and not task.error then
|
||||
self:log(task)
|
||||
elseif task.error or self.view:is_selected(plugin) then
|
||||
if task.error then
|
||||
self:append(vim.trim(task.error), "LazyError", { indent = 4, prefix = "│ " })
|
||||
self:append(vim.trim(task.error), "LazyTaskError", { indent = 6 })
|
||||
self:nl()
|
||||
end
|
||||
if task.output ~= "" and task.output ~= task.error then
|
||||
self:append(vim.trim(task.output), "MsgArea", { indent = 4, prefix = "│ " })
|
||||
elseif task.name == "log" then
|
||||
self:log(task)
|
||||
elseif self.view:is_selected(plugin) and task.output ~= "" and task.output ~= task.error then
|
||||
self:append(vim.trim(task.output), "LazyTaskOutput", { indent = 6 })
|
||||
self:nl()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param task LazyTask
|
||||
function M:log(task)
|
||||
|
@ -414,15 +410,15 @@ function M:log(task)
|
|||
end
|
||||
self:append(ref:sub(1, 7) .. " ", "LazyCommit", { indent = 6 })
|
||||
self:append(vim.trim(msg)):highlight({
|
||||
["#%d+"] = "Number",
|
||||
["^%S+:"] = "Title",
|
||||
["^%S+(%(.*%)):"] = "Italic",
|
||||
["#%d+"] = "LazyCommitIssue",
|
||||
["^%S+:"] = "LazyCommitType",
|
||||
["^%S+(%(.*%)):"] = "LazyCommitScope",
|
||||
["`.-`"] = "@text.literal.markdown_inline",
|
||||
["%*.-%*"] = "Italic",
|
||||
["%*%*.-%*%*"] = "Bold",
|
||||
})
|
||||
-- string.gsub
|
||||
self:append(" " .. time, "Comment")
|
||||
self:append(" " .. time, "LazyComment")
|
||||
self:nl()
|
||||
end
|
||||
self:nl()
|
||||
|
@ -433,9 +429,9 @@ end
|
|||
function M:details(plugin)
|
||||
---@type string[][]
|
||||
local props = {}
|
||||
table.insert(props, { "dir", plugin.dir, "@text.reference" })
|
||||
table.insert(props, { "dir", plugin.dir, "LazyDir" })
|
||||
if plugin.url then
|
||||
table.insert(props, { "url", (plugin.url:gsub("%.git$", "")), "@text.reference" })
|
||||
table.insert(props, { "url", (plugin.url:gsub("%.git$", "")), "LazyUrl" })
|
||||
end
|
||||
local git = Git.info(plugin.dir, true)
|
||||
if git then
|
||||
|
@ -483,7 +479,7 @@ function M:details(plugin)
|
|||
width = math.max(width, #prop[1])
|
||||
end
|
||||
for _, prop in ipairs(props) do
|
||||
self:append(prop[1] .. string.rep(" ", width - #prop[1] + 1), "LazyKey", { indent = 6 })
|
||||
self:append(prop[1] .. string.rep(" ", width - #prop[1] + 1), "LazyProp", { indent = 6 })
|
||||
if type(prop[2]) == "function" then
|
||||
prop[2]()
|
||||
else
|
||||
|
@ -508,12 +504,6 @@ function M:profile()
|
|||
:nl()
|
||||
|
||||
self:nl()
|
||||
local symbols = {
|
||||
"●",
|
||||
"➜",
|
||||
"★",
|
||||
"‒",
|
||||
}
|
||||
|
||||
---@param a LazyProfile
|
||||
---@param b LazyProfile
|
||||
|
@ -543,7 +533,7 @@ function M:profile()
|
|||
end
|
||||
local data = type(entry.data) == "string" and { source = entry.data } or entry.data
|
||||
data.time = entry.time
|
||||
local symbol = symbols[depth] or symbols[#symbols]
|
||||
local symbol = M.list_icon(depth)
|
||||
self:append((" "):rep(depth)):append(symbol, "LazySpecial"):append(" ")
|
||||
self:reason(data, { time_right = true })
|
||||
self:nl()
|
||||
|
@ -557,12 +547,17 @@ function M:profile()
|
|||
end
|
||||
end
|
||||
|
||||
function M.list_icon(depth)
|
||||
local symbols = Config.options.ui.icons.list
|
||||
return symbols[(depth - 1) % #symbols + 1]
|
||||
end
|
||||
|
||||
function M:debug()
|
||||
self:append("Active Handlers", "LazyH2"):nl()
|
||||
self
|
||||
:append(
|
||||
"This shows only the lazy handlers that are still active. When a plugin loads, its handlers are removed",
|
||||
"Comment",
|
||||
"LazyComment",
|
||||
{ indent = 2 }
|
||||
)
|
||||
:nl()
|
||||
|
@ -571,6 +566,7 @@ function M:debug()
|
|||
Util.foreach(handler.active, function(value, plugins)
|
||||
value = type(value) == "table" and value[1] or value
|
||||
if not vim.tbl_isempty(plugins) then
|
||||
---@type string[]
|
||||
plugins = vim.tbl_values(plugins)
|
||||
table.sort(plugins)
|
||||
self:append("● ", "LazySpecial", { indent = 2 })
|
||||
|
@ -590,7 +586,7 @@ function M:debug()
|
|||
local kb = math.floor(#entry.chunk / 10.24) / 100
|
||||
self:append("● ", "LazySpecial", { indent = 2 }):append(modname):append(" " .. kb .. "Kb", "Bold")
|
||||
if entry.modpath ~= modname then
|
||||
self:append(" " .. vim.fn.fnamemodify(entry.modpath, ":p:~:."), "Comment")
|
||||
self:append(" " .. vim.fn.fnamemodify(entry.modpath, ":p:~:."), "LazyComment")
|
||||
end
|
||||
self:nl()
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue