From 6d7b4927dedc9b55b9e7f922c90817497822dc8b Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Tue, 29 Apr 2025 10:20:23 +0200 Subject: [PATCH] feat(nvim-tree): show git branch --- lua/ow/plugins/nvim-tree.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/ow/plugins/nvim-tree.lua b/lua/ow/plugins/nvim-tree.lua index 55e6dd8..fbcaff3 100644 --- a/lua/ow/plugins/nvim-tree.lua +++ b/lua/ow/plugins/nvim-tree.lua @@ -75,7 +75,10 @@ end ---@type LazyPluginSpec return { "nvim-tree/nvim-tree.lua", - dependencies = { "nvim-tree/nvim-web-devicons" }, + dependencies = { + "tpope/vim-fugitive", + "nvim-tree/nvim-web-devicons", + }, event = "VimEnter", keys = { { @@ -168,7 +171,14 @@ return { }, renderer = { full_name = true, - root_folder_label = ":~", + root_folder_label = function(path) + local label = vim.fn.fnamemodify(path, ":~") + local git_head = vim.fn.FugitiveHead() + if git_head ~= "" then + label = label .. (" (%s)"):format(git_head) + end + return label + end, special_files = {}, decorators = { "Git",