From 94908ffb0a84d2ac2fffc4496115da67bad6fe00 Mon Sep 17 00:00:00 2001 From: Laszlo Bacsi Date: Sun, 6 Jul 2025 15:26:42 +0200 Subject: [PATCH] git/neogit: module init --- configuration.nix | 1 + docs/release-notes/rl-0.8.md | 4 +-- modules/plugins/git/default.nix | 1 + modules/plugins/git/gitsigns/config.nix | 2 +- modules/plugins/git/neogit/config.nix | 39 +++++++++++++++++++++++++ modules/plugins/git/neogit/default.nix | 6 ++++ modules/plugins/git/neogit/neogit.nix | 17 +++++++++++ npins/sources.json | 16 ++++++++++ 8 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 modules/plugins/git/neogit/config.nix create mode 100644 modules/plugins/git/neogit/default.nix create mode 100644 modules/plugins/git/neogit/neogit.nix diff --git a/configuration.nix b/configuration.nix index 6f26f040..2e392897 100644 --- a/configuration.nix +++ b/configuration.nix @@ -162,6 +162,7 @@ isMaximal: { enable = true; gitsigns.enable = true; gitsigns.codeActions.enable = false; # throws an annoying debug message + neogit.enable = isMaximal; }; minimap = { diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index c01bc043..2157fcaa 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -433,9 +433,9 @@ [solarized.nvim]: https://github.com/maxmx03/solarized.nvim [smart-splits.nvim]: https://github.com/mrjones2014/smart-splits.nvim +[neogit]: https://github.com/NeogitOrg/neogit - Add [solarized.nvim] theme with support for multiple variants - - Add [smart-splits.nvim] for navigating between Neovim windows and terminal multiplexer panes. Available at `vim.utility.smart-splits`. - +- Add [neogit], an interactive and powerful Git interface for Neovim, inspired by Magit diff --git a/modules/plugins/git/default.nix b/modules/plugins/git/default.nix index 06c80f35..5b30b74a 100644 --- a/modules/plugins/git/default.nix +++ b/modules/plugins/git/default.nix @@ -6,6 +6,7 @@ in { ./vim-fugitive ./git-conflict ./gitlinker-nvim + ./neogit ]; options.vim.git = { diff --git a/modules/plugins/git/gitsigns/config.nix b/modules/plugins/git/gitsigns/config.nix index f5d9f910..e89eebcf 100644 --- a/modules/plugins/git/gitsigns/config.nix +++ b/modules/plugins/git/gitsigns/config.nix @@ -69,7 +69,7 @@ in { }; binds.whichKey.register = pushDownDefault { - "g" = "+Gitsigns"; + "h" = "+Gitsigns"; }; pluginRC.gitsigns = entryAnywhere '' diff --git a/modules/plugins/git/neogit/config.nix b/modules/plugins/git/neogit/config.nix new file mode 100644 index 00000000..20928857 --- /dev/null +++ b/modules/plugins/git/neogit/config.nix @@ -0,0 +1,39 @@ +{ + options, + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.binds) pushDownDefault mkKeymap; + + cfg = config.vim.git.neogit; + + keys = cfg.mappings; + inherit (options.vim.git.neogit) mappings; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["plenary-nvim"]; + + lazy.plugins.neogit = { + package = "neogit"; + setupModule = "neogit"; + inherit (cfg) setupOpts; + + cmd = ["Neogit"]; + + keys = [ + (mkKeymap "n" keys.open "Neogit" {desc = mappings.open.description;}) + (mkKeymap "n" keys.commit "Neogit commit" {desc = mappings.commit.description;}) + (mkKeymap "n" keys.pull "Neogit pull" {desc = mappings.pull.description;}) + (mkKeymap "n" keys.push "Neogit push" {desc = mappings.push.description;}) + ]; + }; + + binds.whichKey.register = pushDownDefault { + "g" = "+Git"; + }; + }; + }; +} diff --git a/modules/plugins/git/neogit/default.nix b/modules/plugins/git/neogit/default.nix new file mode 100644 index 00000000..d3f82759 --- /dev/null +++ b/modules/plugins/git/neogit/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./neogit.nix + ]; +} diff --git a/modules/plugins/git/neogit/neogit.nix b/modules/plugins/git/neogit/neogit.nix new file mode 100644 index 00000000..fa988a32 --- /dev/null +++ b/modules/plugins/git/neogit/neogit.nix @@ -0,0 +1,17 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.git.neogit = { + enable = mkEnableOption "An Interactive and powerful Git interface [Neogit]"; + setupOpts = mkPluginSetupOption "neogit" {}; + + mappings = { + open = mkMappingOption "Git Status [Neogit]" "gs"; + commit = mkMappingOption "Git Commit [Neogit]" "gc"; + pull = mkMappingOption "Git pull [Neogit]" "gp"; + push = mkMappingOption "Git push [Neogit]" "gP"; + }; + }; +} diff --git a/npins/sources.json b/npins/sources.json index 455e1bd6..6b51ae44 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -1530,6 +1530,22 @@ "url": "https://github.com/IogaMaster/neocord/archive/2ebf3792a8100376bb65fd66d5dbf60f50af7529.tar.gz", "hash": "1ycx26ppfb5djxji1mwamr7ra29z8sm0fs9a6hhwn0l69x06x353" }, + "neogit": { + "type": "GitRelease", + "repository": { + "type": "GitHub", + "owner": "NeogitOrg", + "repo": "neogit" + }, + "pre_releases": false, + "version_upper_bound": null, + "release_prefix": null, + "submodules": false, + "version": "v2.0.0", + "revision": "7f97dbfc5af3b898c6660d927c23e3a96a5bd069", + "url": "https://api.github.com/repos/NeogitOrg/neogit/tarball/v2.0.0", + "hash": "0nyv64ai3765if7bdfyx01a0xmsmhm8cjvxyvh2s40bzvkx8xy17" + }, "neorg": { "type": "Git", "repository": {