aboutsummaryrefslogtreecommitdiff
path: root/nvim/lua/config/statusline.lua
diff options
context:
space:
mode:
Diffstat (limited to 'nvim/lua/config/statusline.lua')
-rw-r--r--nvim/lua/config/statusline.lua71
1 files changed, 24 insertions, 47 deletions
diff --git a/nvim/lua/config/statusline.lua b/nvim/lua/config/statusline.lua
index 63c8ba8..fe27cd5 100644
--- a/nvim/lua/config/statusline.lua
+++ b/nvim/lua/config/statusline.lua
@@ -1,13 +1,13 @@
1local M = {} 1local M = {}
2 2
3local modes = { 3local modes = {
4 n = { "NORMAL", "StatuslineModeNormal" }, 4 n = { "NORMAL", "StatuslineModeNormal" },
5 i = { "INSERT", "StatuslineModeInsert" }, 5 i = { "INSERT", "StatuslineModeInsert" },
6 v = { "VISUAL", "StatuslineModeVisual" }, 6 v = { "VISUAL", "StatuslineModeVisual" },
7 V = { "V-LINE", "StatuslineModeVisual" }, 7 V = { "V-LINE", "StatuslineModeVisual" },
8 [""] = { "V-BLOCK", "StatuslineModeVisual" }, 8 [""] = { "V-BLOCK", "StatuslineModeVisual" },
9 R = { "REPLACE", "StatuslineModeReplace" }, 9 R = { "REPLACE", "StatuslineModeReplace" },
10 c = { "COMMAND", "StatuslineModeCommand" }, 10 c = { "COMMAND", "StatuslineModeCommand" },
11} 11}
12 12
13local function mode() 13local function mode()
@@ -35,9 +35,7 @@ local function update_git_branch(bufnr)
35 return 35 return
36 end 36 end
37 37
38 local branch = vim.fn.systemlist( 38 local branch = vim.fn.systemlist("git rev-parse --abbrev-ref HEAD 2>/dev/null")[1]
39 "git rev-parse --abbrev-ref HEAD 2>/dev/null"
40 )[1]
41 39
42 if branch and branch ~= "" then 40 if branch and branch ~= "" then
43 vim.b[bufnr].git_branch = "  " .. branch .. " " 41 vim.b[bufnr].git_branch = "  " .. branch .. " "
@@ -50,14 +48,11 @@ end
50-- Autocmd: Git nur bei Bedarf aktualisieren 48-- Autocmd: Git nur bei Bedarf aktualisieren
51---------------------------------------------------------------------- 49----------------------------------------------------------------------
52 50
53vim.api.nvim_create_autocmd( 51vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained" }, {
54 { "BufEnter", "FocusGained" }, 52 callback = function(args)
55 { 53 update_git_branch(args.buf)
56 callback = function(args) 54 end,
57 update_git_branch(args.buf) 55})
58 end,
59 }
60)
61 56
62---------------------------------------------------------------------- 57----------------------------------------------------------------------
63-- Statusline-Sektionen (reine Darstellung, keine IO) 58-- Statusline-Sektionen (reine Darstellung, keine IO)
@@ -80,9 +75,7 @@ local function git_diff()
80 if gsd.changed and gsd.changed > 0 then table.insert(parts, "~" .. gsd.changed) end 75 if gsd.changed and gsd.changed > 0 then table.insert(parts, "~" .. gsd.changed) end
81 if gsd.removed and gsd.removed > 0 then table.insert(parts, "-" .. gsd.removed) end 76 if gsd.removed and gsd.removed > 0 then table.insert(parts, "-" .. gsd.removed) end
82 77
83 if #parts > 0 then 78 if #parts > 0 then return " " .. table.concat(parts, " ") .. " " end
84 return " " .. table.concat(parts, " ") .. " "
85 end
86 79
87 return "" 80 return ""
88end 81end
@@ -93,13 +86,9 @@ end
93 86
94local function filename() 87local function filename()
95 local name = vim.fn.expand("%:.") 88 local name = vim.fn.expand("%:.")
96 if name == "" then 89 if name == "" then name = "[No Name]" end
97 name = "[No Name]"
98 end
99 90
100 if vim.bo.modified then 91 if vim.bo.modified then name = name .. " [+]" end
101 name = name .. " [+]"
102 end
103 92
104 return " " .. name .. " " 93 return " " .. name .. " "
105end 94end
@@ -110,9 +99,7 @@ end
110 99
111local function treesitter() 100local function treesitter()
112 local ok = vim.treesitter.highlighter.active[vim.api.nvim_get_current_buf()] 101 local ok = vim.treesitter.highlighter.active[vim.api.nvim_get_current_buf()]
113 if ok then 102 if ok then return " 🌳 " end
114 return " 🌳 "
115 end
116 return "" 103 return ""
117end 104end
118 105
@@ -123,9 +110,9 @@ end
123local function diagnostics() 110local function diagnostics()
124 local counts = { 111 local counts = {
125 error = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }), 112 error = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }),
126 warn = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }), 113 warn = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }),
127 info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO }), 114 info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO }),
128 hint = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT }), 115 hint = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT }),
129 } 116 }
130 117
131 local parts = {} 118 local parts = {}
@@ -135,9 +122,7 @@ local function diagnostics()
135 if counts.info > 0 then table.insert(parts, "  " .. counts.info) end 122 if counts.info > 0 then table.insert(parts, "  " .. counts.info) end
136 if counts.hint > 0 then table.insert(parts, "  " .. counts.hint) end 123 if counts.hint > 0 then table.insert(parts, "  " .. counts.hint) end
137 124
138 if #parts > 0 then 125 if #parts > 0 then return " " .. table.concat(parts, " ") .. " " end
139 return " " .. table.concat(parts, " ") .. " "
140 end
141 126
142 return "" 127 return ""
143end 128end
@@ -165,21 +150,13 @@ end
165------------------------------------------------------------------------- 150-------------------------------------------------------------------------
166 151
167local function copilot() 152local function copilot()
168 if vim.fn.exists("*copilot#Enabled") == 0 then 153 if vim.fn.exists("*copilot#Enabled") == 0 then return "" end
169 return ""
170 end
171 154
172 if vim.fn["copilot#Enabled"]() == 0 then 155 if vim.fn["copilot#Enabled"]() == 0 then return "  OFF " end
173 return "  OFF "
174 end
175 156
176 if vim.b.copilot_suggestion and vim.b.copilot_suggestion.is_visible then 157 if vim.b.copilot_suggestion and vim.b.copilot_suggestion.is_visible then return "  SUG " end
177 return "  SUG "
178 end
179 158
180 if vim.b.copilot_suggestion_auto_trigger == false then 159 if vim.b.copilot_suggestion_auto_trigger == false then return "  MAN " end
181 return "  MAN "
182 end
183 160
184 return "  ON " 161 return "  ON "
185end 162end