From ad698dd0aa6e02a7518aa755df3d5a1532e41841 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 4 Nov 2024 11:51:23 +0100 Subject: [PATCH] feat(snacks): use git --- lua/lazyvim/config/keymaps.lua | 3 +-- lua/lazyvim/util/lazygit.lua | 22 +--------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index ffe70bb2..bf9e9b2f 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -130,11 +130,10 @@ if vim.lsp.inlay_hint then end -- lazygit -map("n", "gb", LazyVim.lazygit.blame_line, { desc = "Git Blame Line" }) map("n", "gg", function() Snacks.lazygit( { cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" }) map("n", "gG", function() Snacks.lazygit() end, { desc = "Lazygit (cwd)" }) +map("n", "gb", function() Snacks.git.blame_line() end, { desc = "Git Blame Line" }) map("n", "gB", LazyVim.lazygit.browse, { desc = "Git Browse" }) - map("n", "gf", function() Snacks.lazygit.log_file() end, { desc = "Lazygit Current File History" }) map("n", "gl", function() Snacks.lazygit.log({ cwd = LazyVim.root.git() }) end, { desc = "Lazygit Log" }) map("n", "gL", function() Snacks.lazygit.log() end, { desc = "Lazygit Log (cwd)" }) diff --git a/lua/lazyvim/util/lazygit.lua b/lua/lazyvim/util/lazygit.lua index 6a42f7fd..125c66c7 100644 --- a/lua/lazyvim/util/lazygit.lua +++ b/lua/lazyvim/util/lazygit.lua @@ -1,25 +1,5 @@ ---@class lazyvim.util.lazygit ----@param opts? {count?: number}|LazyCmdOptions -function M.blame_line(opts) - opts = vim.tbl_deep_extend("force", { - count = 3, - interactive = false, - float = { - win = { - width = 0.6, - height = 0.6, - border = "rounded", - }, - bo = { filetype = "git" }, - }, - }, opts or {}) - local cursor = vim.api.nvim_win_get_cursor(0) - local line = cursor[1] - local file = vim.api.nvim_buf_get_name(0) - local root = LazyVim.root.detectors.pattern(0, { ".git" })[1] or "." - local cmd = { "git", "-C", root, "log", "-n", opts.count, "-u", "-L", line .. ",+1:" .. file } - return Snacks.terminal(cmd, opts) -end +local M = {} -- stylua: ignore M.remote_patterns = {