fix: simplify statusline

This commit is contained in:
2026-04-13 03:26:13 +02:00
parent 4e66d2960c
commit d6a9748610
+8 -55
View File
@@ -89,63 +89,16 @@ function _G._status_line_git()
local changed = status.changed or 0
local removed = status.removed or 0
local parts = {}
if added > 0 then
table.insert(
parts,
string.format("%%#GitSignsAdd#+%d%%*", status.added)
)
end
if changed > 0 then
table.insert(
parts,
string.format("%%#GitSignsChange#~%d%%*", status.changed)
)
end
if removed > 0 then
table.insert(
parts,
string.format("%%#GitSignsDelete#-%d%%*", status.removed)
)
end
return table.concat(parts, " ")
return (added + changed + removed) > 0
and "%#NvimTreeGitDirty#M%*"
or ""
end
function _G._status_line_diagnostics()
local diag = vim.diagnostic.count(0)
local err = diag[vim.diagnostic.severity.ERROR] or 0
local warn = diag[vim.diagnostic.severity.WARN] or 0
local hint = diag[vim.diagnostic.severity.HINT] or 0
local info = diag[vim.diagnostic.severity.INFO] or 0
local parts = {}
if err > 0 then
table.insert(parts, string.format("%%#DiagnosticError#E%d%%*", err))
end
if warn > 0 then
table.insert(parts, string.format("%%#DiagnosticWarn#W%d%%*", warn))
end
if hint > 0 then
table.insert(parts, string.format("%%#DiagnosticHint#H%d%%*", hint))
end
if info > 0 then
table.insert(parts, string.format("%%#DiagnosticInfo#I%d%%*", info))
end
return table.concat(parts, " ")
end
vim.opt.statusline = " %{expand('%:.')}%4( %m%) %{%v:lua._status_line_git()%} %="
.. " %{%v:lua._status_line_diagnostics()%} "
.. " %{&filetype} %-6.6{&fileencoding}"
.. " %-4.4{&fileformat} %4.4(%p%%%)%6.6l:%-3.3v"
vim.opt.statusline = " %{expand('%:.')} %{%v:lua._status_line_git()%} %3(%m%)"
.. " %="
.. " %{%v:lua.vim.diagnostic.status()%}"
.. " %{&filetype} %{&fileencoding} %{&fileformat}"
.. " %4(%p%%%) %4l:%-3v"
function _G._quickfix_text_func(info)
local items