From 36f88ca6d776efe13f7cf0bac878738529e53efa Mon Sep 17 00:00:00 2001 From: Nicolas Goudry Date: Sun, 2 Jun 2024 23:22:27 +0200 Subject: [PATCH] feat(plugins): add gitsigns --- plugins/gitsigns.nix | 122 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 plugins/gitsigns.nix diff --git a/plugins/gitsigns.nix b/plugins/gitsigns.nix new file mode 100644 index 0000000..e7061ac --- /dev/null +++ b/plugins/gitsigns.nix @@ -0,0 +1,122 @@ +{ icons, ... }: + +{ + opts = { + enable = true; + + settings = { + current_line_blame = true; + current_line_blame_formatter = " , "; + current_line_blame_formatter_nc = " Uncommitted"; + current_line_blame_opts.ignore_whitespace = true; + + signs = { + add.text = icons.GitSign; + change.text = icons.GitSign; + changedelete.text = icons.GitSign; + delete.text = icons.GitSign; + topdelete.text = icons.GitSign; + untracked.text = icons.GitSign; + }; + }; + }; + + rootOpts = { + # Enable catppuccin colors + # https://github.com/catppuccin/nvim/blob/main/lua/catppuccin/groups/integrations/gitsigns.lua + colorschemes.catppuccin.settings.integrations.gitsigns = true; + + keymaps = [ + { + key = "]g"; + action.__raw = '' + function() + require("gitsigns").next_hunk() + end + ''; + options.desc = "Next Git hunk"; + } + { + key = "[g"; + action.__raw = '' + function() + require("gitsigns").prev_hunk() + end + ''; + options.desc = "Previous Git hunk"; + } + { + key = "gl"; + action.__raw = '' + function() + require("gitsigns").blame_line { full = true } + end + ''; + options.desc = "View full Git blame"; + } + { + key = "gp"; + action.__raw = '' + function() + require("gitsigns").preview_hunk_inline() + end + ''; + options.desc = "Preview Git hunk"; + } + { + key = "gh"; + action.__raw = '' + function() + require("gitsigns").reset_hunk() + end + ''; + options.desc = "Reset Git hunk"; + } + { + key = "gr"; + action.__raw = '' + function() + require("gitsigns").reset_buffer() + end + ''; + options.desc = "Reset Git buffer"; + } + { + key = "gs"; + action.__raw = '' + function() + require("gitsigns").stage_hunk() + end + ''; + options.desc = "Stage Git hunk"; + } + { + key = "gS"; + action.__raw = '' + function() + require("gitsigns").stage_buffer() + end + ''; + options.desc = "Stage Git buffer"; + } + { + key = "gu"; + action.__raw = '' + function() + require("gitsigns").undo_stage_hunk() + end + ''; + options.desc = "Unstage Git hunk"; + } + { + key = "gd"; + action.__raw = '' + function() + require("gitsigns").diffthis() + end + ''; + options.desc = "View Git diff"; + } + ]; + }; +}