This repository has been archived on 2025-01-07. You can view files and clone it, but cannot push or open issues or pull requests.
opdavies.nvim/after/plugin/gitsigns.lua

41 lines
991 B
Lua
Raw Normal View History

local gitsigns_status_ok, gitsigns = pcall(require, "gitsigns")
if not gitsigns_status_ok then
return
end
gitsigns.setup {
linehl = false,
numhl = true,
2023-01-23 18:12:25 +00:00
}
2023-09-04 10:05:13 +00:00
local map = require("opdavies.keymap").map
local nmap = require("opdavies.keymap").nmap
local vmap = require("opdavies.keymap").vmap
2023-08-10 23:26:36 +00:00
2023-10-08 22:54:04 +00:00
nmap { "[h", "<cmd>Gitsigns prev_hunk<CR>" }
nmap { "]h", "<cmd>Gitsigns next_hunk<CR>" }
2023-08-10 23:26:36 +00:00
nmap { "<leader>hR", gitsigns.reset_buffer }
nmap { "<leader>hS", gitsigns.stage_buffer }
nmap { "<leader>hb", gitsigns.blame_line }
nmap { "<leader>hp", gitsigns.preview_hunk }
nmap { "<leader>hr", gitsigns.reset_hunk }
nmap { "<leader>hs", gitsigns.stage_hunk }
nmap { "<leader>hu", gitsigns.undo_stage_hunk }
2024-03-14 01:41:40 +00:00
2023-09-04 10:05:13 +00:00
vmap {
"<leader>hr",
2023-09-04 10:05:13 +00:00
function()
gitsigns.reset_hunk { vim.fn.line ".", vim.fn.line "v" }
end,
}
vmap {
"<leader>hs",
2023-09-04 10:05:13 +00:00
function()
gitsigns.stage_hunk { vim.fn.line ".", vim.fn.line "v" }
end,
}
2023-08-10 23:26:36 +00:00
-- Text object.
2023-09-04 10:05:13 +00:00
map { { "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>" }