aboutsummaryrefslogtreecommitdiff
path: root/lua/pml68
diff options
context:
space:
mode:
authorpml68 <contact@pml68.me>2024-08-16 23:51:12 +0200
committerpml68 <contact@pml68.me>2024-08-16 23:51:12 +0200
commit61c65e671aa199e796ba7fcd51ac063e35ac7465 (patch)
treee331f998b6f627299f2251d3514f8b2949d74de4 /lua/pml68
parentfeat: add 2 remaps (diff)
downloadnvim-61c65e671aa199e796ba7fcd51ac063e35ac7465.tar.gz
feat: add current git branch name to statusline
Diffstat (limited to 'lua/pml68')
-rw-r--r--lua/pml68/settings.lua29
1 files changed, 28 insertions, 1 deletions
diff --git a/lua/pml68/settings.lua b/lua/pml68/settings.lua
index 3958ec6..33e7fd5 100644
--- a/lua/pml68/settings.lua
+++ b/lua/pml68/settings.lua
@@ -4,7 +4,34 @@ vim.o.nu = true
vim.o.conceallevel = 2
vim.o.laststatus = 3
-vim.o.statusline = " %f %m %= [%{&filetype}] %l:%c "
+
+local function branch_name()
+ local branch = vim.fn.system("git branch --show-current 2> /dev/null | tr -d '\n'")
+ if branch ~= "" then
+ return " " .. branch
+ else
+ return ""
+ end
+end
+
+vim.api.nvim_create_autocmd({ "FileType", "BufEnter", "FocusGained" }, {
+ callback = function()
+ vim.b.branch_name = branch_name()
+ end
+})
+
+function Status_Line()
+ return " "
+ .. "%<"
+ .. " %f "
+ .. vim.b.branch_name
+ .. " %m"
+ .. " %="
+ .. " [%{&filetype}]"
+ .. " %l:%c "
+end
+
+vim.opt.statusline = "%{%v:lua.Status_Line()%}"
vim.o.shiftwidth = 2
vim.o.tabstop = 2