aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config/nvim/lua/custom/plugins/git.lua
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2024-05-20 17:08:02 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2024-05-20 17:08:02 +0100
commit079c385b9bd40a73ebafae6d847f62c2bed5126c (patch)
tree95d5e270ac7dab639fe7bca9b7a02041bfadfa47 /home/.config/nvim/lua/custom/plugins/git.lua
parent1d6fe632512eca513dab6a8868298df638e50e5e (diff)
downloaddotfiles-079c385b9bd40a73ebafae6d847f62c2bed5126c.tar.gz
dotfiles-079c385b9bd40a73ebafae6d847f62c2bed5126c.tar.bz2
dotfiles-079c385b9bd40a73ebafae6d847f62c2bed5126c.zip
[nvim] Rewrite config motivated by nvim 0.10
Diffstat (limited to 'home/.config/nvim/lua/custom/plugins/git.lua')
-rw-r--r--home/.config/nvim/lua/custom/plugins/git.lua116
1 files changed, 116 insertions, 0 deletions
diff --git a/home/.config/nvim/lua/custom/plugins/git.lua b/home/.config/nvim/lua/custom/plugins/git.lua
new file mode 100644
index 0000000..adc584c
--- /dev/null
+++ b/home/.config/nvim/lua/custom/plugins/git.lua
@@ -0,0 +1,116 @@
+local map = require("mapper")
+
+return {
+ { 'akinsho/git-conflict.nvim', config = true },
+ {
+ "NeogitOrg/neogit",
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ "nvim-telescope/telescope.nvim",
+ },
+ config = function()
+ local neogit = require("neogit")
+ neogit.setup({
+ disable_commit_confirmation = true,
+ kind = "split",
+ console_timeout = 5000,
+ auto_show_console = false,
+ })
+ map.n("<leader>ng", neogit.open)
+ end,
+ },
+ {
+ "ruifm/gitlinker.nvim",
+ keys = {
+ { "<leader>gy", function() require 'gitlinker'.get_buf_range_url("n") end },
+ {
+ "<leader>gy",
+ function()
+ require 'gitlinker'.get_buf_range_url("v")
+ end,
+ mode = "v"
+ },
+ },
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ },
+ config = function()
+ require "gitlinker".setup({
+ callbacks = {
+ ["personal"] = function(url_data)
+ url_data.host = "github.com"
+ return require "gitlinker.hosts".get_github_type_url(url_data)
+ end,
+ ["work"] = function(url_data)
+ url_data.host = "github.com"
+ return require "gitlinker.hosts".get_github_type_url(url_data)
+ end,
+ ["git.strisemarx.com"] = function(url_data)
+ local url = require "gitlinker.hosts".get_base_https_url(url_data)
+ url = url .. "/tree/" .. url_data.file .. "?id=" .. url_data.rev
+ if url_data.lstart then
+ url = url .. "#n" .. url_data.lstart
+ end
+ return url
+ end
+ },
+ })
+ end,
+ },
+ {
+ "lewis6991/gitsigns.nvim",
+ event = "BufRead",
+ opts = {
+ signs = {
+ change = { show_count = true },
+ delete = { show_count = true },
+ topdelete = { show_count = true },
+ changedelete = { show_count = true },
+ },
+ numhl = true,
+ _extmark_signs = true,
+ _threaded_diff = true,
+ _signs_staged_enable = true,
+ on_attach = function(bufnr)
+ local gs = package.loaded.gitsigns
+
+ -- Navigation
+ map.n(']c', function()
+ if vim.wo.diff then return ']c' end
+ vim.schedule(function() gs.next_hunk() end)
+ return '<Ignore>'
+ end, { expr = true }, bufnr)
+
+ map.n('[c', function()
+ if vim.wo.diff then return '[c' end
+ vim.schedule(function() gs.prev_hunk() end)
+ return '<Ignore>'
+ end, { expr = true }, bufnr)
+
+ -- Actions
+ map.nvcmd('<leader>hs', "Gitsigns stage_hunk", nil, bufnr)
+ map.nvcmd('<leader>hr', "Gitsigns reset_hunk", nil, bufnr)
+ map.n('<leader>hS', gs.stage_buffer, nil, bufnr)
+ map.n('<leader>hu', gs.undo_stage_hunk, nil, bufnr)
+ map.n('<leader>hR', gs.reset_buffer, nil, bufnr)
+ map.n('<leader>hp', gs.preview_hunk, nil, bufnr)
+ map.n('<leader>hb', function() gs.blame_line { full = true } end, nil,
+ bufnr)
+ map.n('<leader>tb', gs.toggle_current_line_blame, nil, bufnr)
+ map.n('<leader>hd', gs.diffthis, nil, bufnr)
+ map.n('<leader>hD', function() gs.diffthis('~') end, nil, bufnr)
+ map.n('<leader>hc', gs.change_base, nil, bufnr)
+ map.n('<leader>hC', function() gs.change_base('~') end, nil, bufnr)
+ map.n('<leader>td', gs.toggle_deleted, nil, bufnr)
+ map.n('<leader>tw', gs.toggle_word_diff, nil, bufnr)
+ map.n('<leader>tl', gs.toggle_linehl, nil, bufnr)
+
+ -- Text object
+ map.map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', nil, bufnr)
+ end
+ },
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ },
+ },
+}