{ config, lib, ... }: let inherit (lib.nixvim) mkRaw; inherit (config.myvim) icons; inherit (config.myvim.mkKey) mkKeymap wKeyObj; in { plugins = { git-conflict = { enable = true; settings.default_mappings = true; }; gitsigns = { enable = true; settings = { current_line_blame = true; preview_config = { border = "rounded"; }; signs = with icons.ui; { add.text = "${LineLeft}"; change.text = "${LineLeft}"; delete.text = "${LineLeft}"; topdelete.text = "${Triangle}"; changedelete.text = "${BoldLineLeft}"; }; }; }; neogit = { enable = true; settings = { graph_style = "unicode"; process_spinner = true; git_services = { "bitbucket.eu.seeds.basf.net" = { pull_request = "https://bitbucket.eu.seeds.basf.net/projects/\${owner}/repos/\${repository}/pull-requests/new?source=\${branch_name}&t=1"; commit = "https://bitbucket.eu.seeds.basf.net/projects/\${owner}/repos/\${repository}/commits/\${oid}"; tree = "https://bitbucket.eu.seeds.basf.net/projects/\${owner}/repos/\${repository}/browse?at=refs%2Fheads%2F\${branch_name}"; }; "codeberg.org" = { pull_request = "https://\${host}/\${owner}/\${repository}/compare/\${branch_name}"; commit = "https://\${host}/\${owner}/\${repository}/commit/\${oid}"; tree = "https://\${host}/\${owner}/\${repository}/src/branch/\${branch_name}"; }; "github.com" = { pull_request = "https://github.com/\${owner}/\${repository}/compare/\${branch_name}?expand=1"; commit = "https://github.com/\${owner}/\${repository}/commit/\${oid}"; tree = "https://github.com/\${owner}/\${repository}/tree/\${branch_name}"; }; }; }; }; }; wKeyList = [ (wKeyObj [ "g" "" "git" ]) (wKeyObj [ "gh" "󰫅" "hunks" ]) (wKeyObj [ "gb" "󰭐" "blame" ]) ]; keymaps = [ # Navigation (mkKeymap "n" "]h" ( # lua mkRaw '' function () if vim.wo.diff then vim.cmd.normal ({ ' ]c', bang = true}) else require('gitsigns').nav_hunk('next') end end '' ) "Next Hunk") (mkKeymap "n" "[h" ( # lua mkRaw '' function() if vim.wo.diff then vim.cmd.normal({'[c', bang = true}) else require('gitsigns').nav_hunk('prev') end end '' ) "Prev Hunk") (mkKeymap "n" "]H" (mkRaw "function() require('gitsigns').nav_hunk('last') end") "Last Hunk") (mkKeymap "n" "[H" (mkRaw "function() require('gitsigns').nav_hunk('first') end") "First Hunk") (mkKeymap "n" "gn" "Neogit" "Neogit") # Stage / Reset (mkKeymap "n" "gs" "lua require('gitsigns').stage_buffer()" "Stage Buffer") (mkKeymap "v" "gs" ( # lua mkRaw '' function() require('gitsigns').stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) end '' ) "Stage/Unstage Selection") (mkKeymap "n" "gr" "lua require('gitsigns').reset_buffer()" "Reset Buffer") (mkKeymap "v" "gr" ( # lua mkRaw '' function() require('gitsigns').reset_hunk({ vim.fn.line('.'), vim.fn.line('v') }) end '' ) "Reset Selection") # Undo (mkKeymap "n" "gu" "lua require('gitsigns').undo_stage_hunk()" "Undo Stage Hunk") # Preview / Diff (mkKeymap "n" "gp" "lua require('gitsigns').preview_hunk_inline()" "Preview Hunk Inline" ) (mkKeymap "n" "gP" "lua require('gitsigns').preview_hunk()" "Preview Hunk (Popup)") (mkKeymap "v" "gp" ( # lua mkRaw '' function() require('gitsigns').preview_hunk_inline({ vim.fn.line('.'), vim.fn.line('v') }) end '' ) "Preview Selection") (mkKeymap "n" "dg" "lua require('gitsigns').diffthis()" "Git Diff ") (mkKeymap "n" "dG" (mkRaw "function() require('gitsigns').diffthis('~') end") "Git diff last commit (HEAD~)" ) # Blame (mkKeymap "n" "gk" (mkRaw "function() require('gitsigns').blame_line({ full = true }) end") "Blame Line (Full)" ) (mkKeymap "n" "gK" ":lua require('gitsigns').blame()" "Blame File") # Quickfix (mkKeymap "n" "gq" ":lua require('gitsigns').setqflist()" "Hunks to Quickfix") (mkKeymap "n" "gQ" (mkRaw "function() require('gitsigns').setqflist('all') end") "All Hunks to Quickfix" ) # Toggles (mkKeymap "n" "gb" "lua require('gitsigns').toggle_current_line_blame()" "Toggle Blame (Line)" ) (mkKeymap "n" "gw" "lua require('gitsigns').toggle_word_diff()" "Toggle Word Diff") # Text object (mkKeymap "o" "ih" ":Gitsigns select_hunk" "Select Hunk") (mkKeymap "x" "ih" ":Gitsigns select_hunk" "Select Hunk") ]; }