From 91c4ddc53c3bb1549b83338015e9148225bd8b8c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 14 Mar 2024 00:06:13 +0100 Subject: [PATCH] refactor: cleanup --- lua/lazyvim/config/keymaps.lua | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 88408c68..e829973d 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -129,17 +129,9 @@ map("n", "ub", function() Util.toggle("background", false, {"light", "da map("n", "gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) map("n", "gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) -local current_file_path_from_git_root = function() - local path = vim.fn.expand("%:p") - local root = vim.fn.system("git -C " .. path .. " rev-parse --show-toplevel"):gsub("\n$", "") - if not path:find(root, 1, true) then - return path - end - return path:sub(#root + 2) -end - map("n", "gf", function() - Util.terminal({ "lazygit", "-f", current_file_path_from_git_root() }, { esc_esc = false, ctrl_hjkl = false }) + local git_path = vim.fn.system("git ls-files --full-name " .. vim.api.nvim_buf_get_name(0)) + Util.terminal({ "lazygit", "-f", vim.trim(git_path) }, { esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit current file history" }) -- quit