From 04042907c77f9790f78df0b6af52dbdd6e89ca55 Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Thu, 23 May 2024 18:59:24 -0400 Subject: Better auto-cd into git root -> consistent harpoon --- lua/core/init.lua | 1 + lua/plugins/fugitive.lua | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lua/core/init.lua b/lua/core/init.lua index 7b47875..cd99ee5 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -23,3 +23,4 @@ vim.keymap.set("v", "", ":m '<-2gv=gv") vim.g.netrw_liststyle = 3 vim.g.netrw_banner = 0 vim.g.netrw_bufsettings = "noma nomod nu nobl nowrap ro" + diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua index 12a6385..ce5e173 100644 --- a/lua/plugins/fugitive.lua +++ b/lua/plugins/fugitive.lua @@ -1,6 +1,19 @@ return { + lazy = false, "tpope/vim-fugitive", dependencies = "tpope/vim-rhubarb", + config = function() + + local handle = io.popen('git rev-parse --is-inside-work-tree 2> /dev/null') + if handle then + local result = handle:read('*a') + handle:close() + if result and result:match('true') then + vim.cmd([[Gcd]]) + end + end + + end, -- Only load when using one of the following commands: keys = { { "gs", "G" }, -- G.it S.tatus -- cgit v1.2.3