From dc56df433bfbf107fee0139e187eb9750878fa84 Mon Sep 17 00:00:00 2001 From: akan Date: Mon, 8 Jul 2024 22:26:34 +0200 Subject: [PATCH] Get the path of current file relative to the git root --- lua/lazygit.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index a5662b3..764247b 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -138,8 +138,11 @@ end --- :LazyGitFilterCurrentFile entry point local function lazygitfiltercurrentfile() - local current_file = vim.fn.expand("%") - lazygitfilter(current_file) + local current_dir = vim.fn.expand("%:p:h") + local git_root = get_root(current_dir) + local file_path = vim.fn.expand('%:p') + local relative_path = string.sub(file_path, #git_root + 2) + lazygitfilter(relative_path) end --- :LazyGitConfig entry point