fix: simplify statusline
This commit is contained in:
+8
-55
@@ -89,63 +89,16 @@ function _G._status_line_git()
|
|||||||
local changed = status.changed or 0
|
local changed = status.changed or 0
|
||||||
local removed = status.removed or 0
|
local removed = status.removed or 0
|
||||||
|
|
||||||
local parts = {}
|
return (added + changed + removed) > 0
|
||||||
|
and "%#NvimTreeGitDirty#M%*"
|
||||||
if added > 0 then
|
or ""
|
||||||
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, " ")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function _G._status_line_diagnostics()
|
vim.opt.statusline = " %{expand('%:.')} %{%v:lua._status_line_git()%} %3(%m%)"
|
||||||
local diag = vim.diagnostic.count(0)
|
.. " %="
|
||||||
local err = diag[vim.diagnostic.severity.ERROR] or 0
|
.. " %{%v:lua.vim.diagnostic.status()%}"
|
||||||
local warn = diag[vim.diagnostic.severity.WARN] or 0
|
.. " %{&filetype} %{&fileencoding} %{&fileformat}"
|
||||||
local hint = diag[vim.diagnostic.severity.HINT] or 0
|
.. " %4(%p%%%) %4l:%-3v"
|
||||||
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"
|
|
||||||
|
|
||||||
function _G._quickfix_text_func(info)
|
function _G._quickfix_text_func(info)
|
||||||
local items
|
local items
|
||||||
|
|||||||
Reference in New Issue
Block a user