aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nvim/lua/config/statusline.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/nvim/lua/config/statusline.lua b/nvim/lua/config/statusline.lua
index 0ec6579..8a9c75a 100644
--- a/nvim/lua/config/statusline.lua
+++ b/nvim/lua/config/statusline.lua
@@ -20,6 +20,10 @@ end
20-- Git branch (buffer-lokal, gecached, kein redraw-spam) 20-- Git branch (buffer-lokal, gecached, kein redraw-spam)
21---------------------------------------------------------------------- 21----------------------------------------------------------------------
22 22
23-- /dev/null gibt es unter Windows nicht (cmd.exe versteht das nicht als
24-- Pfad und meldet "Das System kann den angegebenen Pfad nicht finden").
25local devnull = vim.fn.has("win32") == 1 and "NUL" or "/dev/null"
26
23local function update_git_branch(bufnr) 27local function update_git_branch(bufnr)
24 bufnr = bufnr or 0 28 bufnr = bufnr or 0
25 29
@@ -35,7 +39,12 @@ local function update_git_branch(bufnr)
35 return 39 return
36 end 40 end
37 41
38 local branch = vim.fn.systemlist("git rev-parse --abbrev-ref HEAD 2>/dev/null")[1] 42 local branch = vim.fn.systemlist("git rev-parse --abbrev-ref HEAD 2>" .. devnull)[1]
43 if branch then
44 -- unter Windows bleibt an systemlist()-Zeilen mitunter ein
45 -- trailing \r haengen (^M in der Statuszeile sichtbar)
46 branch = branch:gsub("\r$", "")
47 end
39 48
40 if branch and branch ~= "" then 49 if branch and branch ~= "" then
41 vim.b[bufnr].git_branch = "  " .. branch .. " " 50 vim.b[bufnr].git_branch = "  " .. branch .. " "