aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nvim/lua/config/colorscheme.lua7
-rw-r--r--nvim/lua/config/options.lua4
-rw-r--r--nvim/lua/config/statusline.lua165
3 files changed, 176 insertions, 0 deletions
diff --git a/nvim/lua/config/colorscheme.lua b/nvim/lua/config/colorscheme.lua
index 22833bb..88cc8c0 100644
--- a/nvim/lua/config/colorscheme.lua
+++ b/nvim/lua/config/colorscheme.lua
@@ -22,3 +22,10 @@ vim.api.nvim_set_hl(0, "SpellLocal", {
22vim.api.nvim_set_hl(0, "CursorLine", { 22vim.api.nvim_set_hl(0, "CursorLine", {
23 bg = "#252526" 23 bg = "#252526"
24}) 24})
25
26-- Statusline Farben
27vim.api.nvim_set_hl(0, "StatuslineModeNormal", { fg = "#1e222a", bg = "#61afef", bold = true })
28vim.api.nvim_set_hl(0, "StatuslineModeInsert", { fg = "#1e222a", bg = "#98c379", bold = true })
29vim.api.nvim_set_hl(0, "StatuslineModeVisual", { fg = "#1e222a", bg = "#c678dd", bold = true })
30vim.api.nvim_set_hl(0, "StatuslineModeReplace",{ fg = "#1e222a", bg = "#e86671", bold = true })
31vim.api.nvim_set_hl(0, "StatuslineModeCommand",{ fg = "#1e222a", bg = "#e5c07b", bold = true })
diff --git a/nvim/lua/config/options.lua b/nvim/lua/config/options.lua
index 097e5d6..91a8189 100644
--- a/nvim/lua/config/options.lua
+++ b/nvim/lua/config/options.lua
@@ -82,6 +82,10 @@ opt.undofile = true
82opt.undolevels = 10000 82opt.undolevels = 10000
83opt.undoreload = 10000 83opt.undoreload = 10000
84 84
85-- Statusline
86opt.laststatus = 2
87opt.statusline = "%!v:lua.require('config.statusline').statusline()"
88
85-- Clipboard 89-- Clipboard
86opt.clipboard = "unnamedplus" 90opt.clipboard = "unnamedplus"
87 91
diff --git a/nvim/lua/config/statusline.lua b/nvim/lua/config/statusline.lua
new file mode 100644
index 0000000..fb89a66
--- /dev/null
+++ b/nvim/lua/config/statusline.lua
@@ -0,0 +1,165 @@
1local M = {}
2
3local modes = {
4 n = { "NORMAL", "StatuslineModeNormal" },
5 i = { "INSERT", "StatuslineModeInsert" },
6 v = { "VISUAL", "StatuslineModeVisual" },
7 V = { "V-LINE", "StatuslineModeVisual" },
8 [""] = { "V-BLOCK", "StatuslineModeVisual" },
9 R = { "REPLACE", "StatuslineModeReplace" },
10 c = { "COMMAND", "StatuslineModeCommand" },
11}
12
13local function mode()
14 local m = vim.fn.mode()
15 local entry = modes[m] or { m, "StatusLine" }
16 return string.format("%%#%s# %s %%#StatusLine#", entry[2], entry[1])
17end
18
19----------------------------------------------------------------------
20-- Git branch (buffer-lokal, gecached, kein redraw-spam)
21----------------------------------------------------------------------
22
23local function update_git_branch(bufnr)
24 bufnr = bufnr or 0
25
26 -- nur in echten Dateien
27 if vim.bo[bufnr].buftype ~= "" then
28 vim.b[bufnr].git_branch = ""
29 return
30 end
31
32 -- kein Git → nichts tun
33 if vim.fn.executable("git") ~= 1 then
34 vim.b[bufnr].git_branch = ""
35 return
36 end
37
38 local branch = vim.fn.systemlist(
39 "git rev-parse --abbrev-ref HEAD 2>/dev/null"
40 )[1]
41
42 if branch and branch ~= "" then
43 vim.b[bufnr].git_branch = "  " .. branch .. " "
44 else
45 vim.b[bufnr].git_branch = ""
46 end
47end
48
49----------------------------------------------------------------------
50-- Autocmd: Git nur bei Bedarf aktualisieren
51----------------------------------------------------------------------
52
53vim.api.nvim_create_autocmd(
54 { "BufEnter", "FocusGained" },
55 {
56 callback = function(args)
57 update_git_branch(args.buf)
58 end,
59 }
60)
61
62----------------------------------------------------------------------
63-- Statusline-Sektionen (reine Darstellung, keine IO)
64----------------------------------------------------------------------
65
66local function git()
67 return vim.b.git_branch or ""
68end
69
70local function git_diff()
71 local gsd = vim.b.gitsigns_status_dict
72 if not gsd then return "" end
73
74 local parts = {}
75 if gsd.added and gsd.added > 0 then table.insert(parts, "+" .. gsd.added) end
76 if gsd.changed and gsd.changed > 0 then table.insert(parts, "~" .. gsd.changed) end
77 if gsd.removed and gsd.removed > 0 then table.insert(parts, "-" .. gsd.removed) end
78
79 if #parts > 0 then
80 return " " .. table.concat(parts, " ") .. " "
81 end
82
83 return ""
84end
85
86local function filename()
87 local name = vim.fn.expand("%:t")
88 if name == "" then
89 name = "[No Name]"
90 end
91
92 if vim.bo.modified then
93 name = name .. " [+]"
94 end
95
96 return " " .. name .. " "
97end
98
99local function treesitter()
100 local ok = vim.treesitter.highlighter.active[vim.api.nvim_get_current_buf()]
101 if ok then
102 return " 🌳 "
103 end
104 return ""
105end
106
107local function diagnostics()
108 local counts = {
109 error = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }),
110 warn = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }),
111 info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO }),
112 hint = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT }),
113 }
114
115 local parts = {}
116
117 if counts.error > 0 then table.insert(parts, "  " .. counts.error) end
118 if counts.warn > 0 then table.insert(parts, "  " .. counts.warn) end
119 if counts.info > 0 then table.insert(parts, "  " .. counts.info) end
120 if counts.hint > 0 then table.insert(parts, "  " .. counts.hint) end
121
122 if #parts > 0 then
123 return " " .. table.concat(parts, " ") .. " "
124 end
125
126 return ""
127end
128
129local function fileinfo()
130 local ft = vim.bo.filetype ~= "" and vim.bo.filetype or "none"
131 local enc = vim.bo.fileencoding ~= "" and vim.bo.fileencoding or vim.o.encoding
132 return string.format(" %s %s ", ft, enc)
133end
134
135local function position()
136 return string.format(" %d:%d ", vim.fn.line("."), vim.fn.col("."))
137end
138
139----------------------------------------------------------------------
140-- Öffentliche Statusline-Funktion
141----------------------------------------------------------------------
142
143function M.statusline()
144 return table.concat({
145 -- LEFT: Mode & Context
146 mode(),
147 "%#PmenuSel#",
148 git(),
149 git_diff(),
150 "%#StatusLine#",
151 filename(),
152
153 "%=",
154
155 -- RIGHT: Feedback & Meta
156 diagnostics(),
157 treesitter(),
158 "%#StatusLineNC#",
159 fileinfo(),
160 " %p%% ",
161 position(),
162 })
163end
164
165return M