diff options
| author | pml68 <contact@pml68.me> | 2024-08-16 23:51:12 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.me> | 2024-08-16 23:51:12 +0200 |
| commit | 61c65e671aa199e796ba7fcd51ac063e35ac7465 (patch) | |
| tree | e331f998b6f627299f2251d3514f8b2949d74de4 /lua/pml68/settings.lua | |
| parent | feat: add 2 remaps (diff) | |
| download | nvim-61c65e671aa199e796ba7fcd51ac063e35ac7465.tar.gz | |
feat: add current git branch name to statusline
Diffstat (limited to '')
| -rw-r--r-- | lua/pml68/settings.lua | 29 |
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 |
