Files
Neovim/lua/plugins/heirline.lua
T
faumaray b5f1714ee7 update
Signed-off-by: faumaray <faumaray@gmail.com>
2026-04-20 01:50:04 +03:00

171 lines
5.0 KiB
Lua

return {
"rebelot/heirline.nvim",
dependencies = { "Zeioth/heirline-components.nvim" },
opts = function()
local utils = require("heirline.utils")
local function setup_colors()
return {
bright_bg = utils.get_highlight("Folded").bg,
bright_fg = utils.get_highlight("Folded").fg,
red = utils.get_highlight("DiagnosticError").fg,
dark_red = utils.get_highlight("DiffDelete").bg,
green = utils.get_highlight("String").fg,
blue = utils.get_highlight("Function").fg,
gray = utils.get_highlight("NonText").fg,
orange = utils.get_highlight("Constant").fg,
purple = utils.get_highlight("Statement").fg,
cyan = utils.get_highlight("Special").fg,
diag_warn = utils.get_highlight("DiagnosticWarn").fg,
diag_error = utils.get_highlight("DiagnosticError").fg,
diag_hint = utils.get_highlight("DiagnosticHint").fg,
diag_info = utils.get_highlight("DiagnosticInfo").fg,
git_del = utils.get_highlight("diffDeleted").fg,
git_add = utils.get_highlight("diffAdded").fg,
git_change = utils.get_highlight("diffChanged").fg,
}
end
-- require("heirline").load_colors(setup_colors)
-- or pass it to config.opts.colors
vim.api.nvim_create_augroup("Heirline", { clear = true })
vim.api.nvim_create_autocmd("ColorScheme", {
callback = function()
utils.on_colorscheme(setup_colors)
end,
group = "Heirline",
})
local Spacer = { provider = " " }
local function rpad(child)
return {
condition = child.condition,
child,
Spacer,
}
end
local function OverseerTasksForStatus(status)
return {
condition = function(self)
return self.tasks[status]
end,
provider = function(self)
return string.format("%s%d", self.symbols[status], #self.tasks[status])
end,
hl = function(self)
return {
fg = utils.get_highlight(string.format("Overseer%s", status)).fg,
}
end,
}
end
local Overseer = {
condition = function()
return package.loaded.overseer
end,
init = function(self)
local tasks = require("overseer.task_list").list_tasks({ unique = true, include_ephemeral = true })
local tasks_by_status = require("overseer.util").tbl_group_by(tasks, "status")
self.tasks = tasks_by_status
end,
static = {
symbols = {
["CANCELED"] = " ",
["FAILURE"] = "󰅚 ",
["SUCCESS"] = "󰄴 ",
["RUNNING"] = "󰑮 ",
},
},
rpad(OverseerTasksForStatus("CANCELED")),
rpad(OverseerTasksForStatus("RUNNING")),
rpad(OverseerTasksForStatus("SUCCESS")),
rpad(OverseerTasksForStatus("FAILURE")),
}
local lib = require("heirline-components.all")
return {
opts = {
disable_winbar_cb = function(args) -- We do this to avoid showing it on the greeter.
local is_disabled = not require("heirline-components.buffer").is_valid(args.buf)
or lib.condition.buffer_matches({
buftype = { "terminal", "prompt", "nofile", "help", "quickfix" },
filetype = { "NvimTree", "neo%-tree", "dashboard", "Outline", "aerial" },
}, args.buf)
return is_disabled
end,
},
tabline = { -- UI upper bar
-- lib.component.tabline_conditional_padding(),
-- lib.component.tabline_buffers(),
-- lib.component.fill { hl = { bg = "tabline_bg" } },
-- lib.component.tabline_tabpages()
},
winbar = { -- UI breadcrumbs bar
init = function(self)
self.bufnr = vim.api.nvim_get_current_buf()
end,
fallthrough = false,
-- Winbar for terminal, neotree, and aerial.
{
condition = function()
return not lib.condition.is_active()
end,
{
lib.component.neotree(),
lib.component.compiler_play(),
lib.component.fill(),
lib.component.compiler_build_type(),
lib.component.compiler_redo(),
lib.component.aerial(),
},
},
-- Regular winbar
{
lib.component.neotree(),
lib.component.compiler_play(),
lib.component.fill(),
lib.component.breadcrumbs(),
lib.component.fill(),
lib.component.compiler_redo(),
lib.component.aerial(),
},
},
statuscolumn = { -- UI left column
init = function(self)
self.bufnr = vim.api.nvim_get_current_buf()
end,
lib.component.foldcolumn(),
lib.component.numbercolumn(),
lib.component.signcolumn(),
} or nil,
statusline = { -- UI statusbar
hl = { fg = "fg", bg = "bg" },
lib.component.mode(),
lib.component.git_branch(),
lib.component.file_info(),
lib.component.git_diff(),
lib.component.diagnostics(),
Overseer,
lib.component.fill(),
lib.component.cmd_info(),
lib.component.fill(),
lib.component.lsp(),
lib.component.compiler_state(),
lib.component.virtual_env(),
lib.component.nav(),
lib.component.mode({ surround = { separator = "right" } }),
},
}
end,
config = function(_, opts)
local heirline = require("heirline")
local heirline_components = require("heirline-components.all")
-- Setup
heirline_components.init.subscribe_to_events()
heirline.load_colors(heirline_components.hl.get_colors())
heirline.setup(opts)
end,
}