1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
local M = {}
local modes = {
n = { "NORMAL", "StatuslineModeNormal" },
i = { "INSERT", "StatuslineModeInsert" },
v = { "VISUAL", "StatuslineModeVisual" },
V = { "V-LINE", "StatuslineModeVisual" },
[""] = { "V-BLOCK", "StatuslineModeVisual" },
R = { "REPLACE", "StatuslineModeReplace" },
c = { "COMMAND", "StatuslineModeCommand" },
}
local function mode()
local m = vim.fn.mode()
local entry = modes[m] or { m, "StatusLine" }
return string.format("%%#%s# %s %%#StatusLine#", entry[2], entry[1])
end
----------------------------------------------------------------------
-- Statusline-Sektionen (reine Darstellung, keine IO)
----------------------------------------------------------------------
-- Git-Branch (gitsigns setzt vim.b.gitsigns_head asynchron pro Buffer)
local function git()
local head = vim.b.gitsigns_head
if not head or head == "" then return "" end
return " " .. head .. " "
end
-- Git-Diff (buffer-lokal, kein redraw-spam)
local function git_diff()
local gsd = vim.b.gitsigns_status_dict
if not gsd then return "" end
local parts = {}
if gsd.added and gsd.added > 0 then table.insert(parts, "+" .. gsd.added) end
if gsd.changed and gsd.changed > 0 then table.insert(parts, "~" .. gsd.changed) end
if gsd.removed and gsd.removed > 0 then table.insert(parts, "-" .. gsd.removed) end
if #parts > 0 then return " " .. table.concat(parts, " ") .. " " end
return ""
end
----------------------------------------------------------------------
-- Dateiname mit Modifikationsstatus
----------------------------------------------------------------------
local function filename()
local name = vim.fn.expand("%:.")
if name == "" then name = "[No Name]" end
if vim.bo.modified then name = name .. " [+]" end
return " " .. name .. " "
end
------------------------------------------------------------------------
-- Treesitter-Aktivität (buffer-lokal, kein redraw-spam)
------------------------------------------------------------------------
local function treesitter()
local ok = vim.treesitter.highlighter.active[vim.api.nvim_get_current_buf()]
if ok then return " 🌳 " end
return ""
end
------------------------------------------------------------------------
-- Diagnostik-Counts (buffer-lokal, kein redraw-spam)
------------------------------------------------------------------------
local function diagnostics()
local counts = {
error = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }),
warn = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }),
info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO }),
hint = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT }),
}
local parts = {}
if counts.error > 0 then table.insert(parts, " " .. counts.error) end
if counts.warn > 0 then table.insert(parts, " " .. counts.warn) end
if counts.info > 0 then table.insert(parts, " " .. counts.info) end
if counts.hint > 0 then table.insert(parts, " " .. counts.hint) end
if #parts > 0 then return " " .. table.concat(parts, " ") .. " " end
return ""
end
------------------------------------------------------------------------
-- Filetype & Encoding (buffer-lokal, kein redraw-spam)
------------------------------------------------------------------------
local function fileinfo()
local ft = vim.bo.filetype ~= "" and vim.bo.filetype or "none"
local enc = vim.bo.fileencoding ~= "" and vim.bo.fileencoding or vim.o.encoding
return string.format(" %s %s ", ft, enc)
end
------------------------------------------------------------------------
-- Cursor-Position (kein redraw-spam)
------------------------------------------------------------------------
local function position()
return string.format(" %d:%d ", vim.fn.line("."), vim.fn.col("."))
end
----------------------------------------------------------------------
-- Öffentliche Statusline-Funktion
----------------------------------------------------------------------
function M.statusline()
return table.concat({
-- LEFT: Mode & Context
mode(),
"%#PmenuSel#",
git(),
git_diff(),
"%#StatusLine#",
filename(),
"%=",
-- RIGHT: Feedback & Meta
diagnostics(),
treesitter(),
fileinfo(),
" %p%% ",
position(),
})
end
return M
|