diff --git a/lazy-lock.json b/lazy-lock.json index ea97082..9178578 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -11,6 +11,7 @@ "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, "blink.compat": { "branch": "main", "commit": "2ed6d9a28b07fa6f3bface818470605f8896408c" }, "cmp-dap": { "branch": "master", "commit": "ea92773e84c0ad3288c3bc5e452ac91559669087" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, "github-nvim-theme": { "branch": "main", "commit": "c106c9472154d6b2c74b74565616b877ae8ed31d" }, "gitsigns.nvim": { "branch": "main", "commit": "7010000889bfb6c26065e0b0f7f1e6aa9163edd9" }, @@ -27,6 +28,7 @@ "mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" }, "neo-tree.nvim": { "branch": "main", "commit": "84c75e7a7e443586f60508d12fc50f90d9aee14e" }, "neoconf.nvim": { "branch": "main", "commit": "bbe36f4d60ed096282f564ddae4e781e420a8270" }, + "neogit": { "branch": "master", "commit": "395ac481e197784e410b59b987fadaf9e7481df1" }, "none-ls.nvim": { "branch": "main", "commit": "3c206dfedf5f1385e9d29f85ffaec7874358592a" }, "nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" }, "nvim-autopairs": { "branch": "master", "commit": "c2a0dd0d931d0fb07665e1fedb1ea688da3b80b4" }, diff --git a/lua/plugins/astrocommunity.lua b/lua/plugins/astrocommunity.lua index c56df10..711240a 100644 --- a/lua/plugins/astrocommunity.lua +++ b/lua/plugins/astrocommunity.lua @@ -1,5 +1,7 @@ return { "AstroNvim/astrocommunity", { import = "astrocommunity.colorscheme.github-nvim-theme" }, + { import = "astrocommunity.git.neogit" }, + { import = "astrocommunity.git.diffview-nvim" }, { import = "astrocommunity.markdown-and-latex.vimtex" }, } diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua new file mode 100644 index 0000000..37e933d --- /dev/null +++ b/lua/plugins/git.lua @@ -0,0 +1,75 @@ +return { + { + "AstroNvim/astrocore", + opts = function(_, opts) + local maps = opts.mappings + maps.n = maps.n or {} + maps.x = maps.x or {} + + -- Keep g focused on repo UI, while hunk actions stay buffer-local in gitsigns. + maps.n["g"] = { desc = "Git" } + + maps.n["gg"] = false + maps.n["gb"] = false + maps.n["gc"] = false + maps.n["gC"] = false + maps.n["gt"] = false + maps.n["gT"] = false + maps.n["go"] = false + maps.x["go"] = false + + maps.n["gn"] = false + maps.n["gnt"] = false + maps.n["gnc"] = false + maps.n["gnd"] = false + maps.n["gnk"] = false + maps.n["gnf"] = false + maps.n["gnh"] = false + maps.n["gnv"] = false + + end, + }, + { + "NeogitOrg/neogit", + keys = { + { "gg", "Neogit", desc = "Git status" }, + { "gb", "Neogit branch", desc = "Git branches" }, + { "gc", "Neogit commit", desc = "Git commit" }, + { "gs", "Neogit stash", desc = "Git stash" }, + }, + opts = function(_, opts) + opts.integrations = opts.integrations or {} + opts.integrations.diffview = true + return opts + end, + }, + { + "sindrets/diffview.nvim", + cmd = { "DiffviewOpen", "DiffviewClose", "DiffviewFileHistory" }, + keys = { + { "gd", "DiffviewOpen", desc = "Git diff" }, + { "gD", "DiffviewClose", desc = "Git diff close" }, + { "gh", "DiffviewFileHistory %", desc = "Git history (file)" }, + { "gH", "DiffviewFileHistory", desc = "Git history (repo)" }, + }, + }, + { + "lewis6991/gitsigns.nvim", + opts = function(_, opts) + -- Gitsigns owns only in-buffer hunk work, so its maps stay local and minimal. + opts.on_attach = function(bufnr) + local gitsigns = require "gitsigns" + local map = function(lhs, rhs, desc) + vim.keymap.set("n", lhs, rhs, { buffer = bufnr, desc = desc }) + end + + map("gl", gitsigns.blame_line, "View Git blame") + map("gp", gitsigns.preview_hunk, "Preview Git hunk") + map("]h", function() gitsigns.nav_hunk "next" end, "Next Git hunk") + map("[h", function() gitsigns.nav_hunk "prev" end, "Previous Git hunk") + end + + return opts + end, + }, +}