Neovim: add more git keybinds

This commit is contained in:
Marko Korhonen 2024-10-17 10:04:51 +03:00
parent 5328c00cf5
commit e073807f40
No known key found for this signature in database
GPG Key ID: A7F78BCB859CD890
2 changed files with 30 additions and 3 deletions

View File

@ -1,3 +1,5 @@
local k = vim.keymap.set
-- Git commands
--- @type LazyPluginSpec
return {
@ -8,5 +10,30 @@ return {
"https://git.korhonen.cc",
"https://git.rossum.fi",
}
-- Keybinds
k("n", "<leader>gs", function()
vim.cmd("Git status")
end, { desc = "Status" })
k("n", "<leader>gaa", function()
vim.cmd("Git add -A")
end, { desc = "All" })
k("n", "<leader>gc", function()
vim.cmd("Git commit")
end, { desc = "Commit" })
k("n", "<leader>gu", function()
vim.cmd("Git push")
end, { desc = "Push" })
k("n", "<leader>gd", function()
vim.cmd("Git pull")
end, { desc = "Pull" })
k({ "n", "x" }, "<leader>gb", function()
vim.cmd("GBrowse")
end, { desc = "Browse" })
end,
}

View File

@ -7,6 +7,9 @@ return {
local gs = require("gitsigns")
gs.setup()
-- Keybinds
local opts
-- Add groups for which-key
require("which-key").add({
{ "<leader>g", group = "Git" },
@ -14,9 +17,6 @@ return {
{ "<leader>ga", group = "Add" },
})
-- Keybinds
local opts
-- Hunk navigation
k("n", "[h", gs.prev_hunk, { desc = "Previous hunk" })
k("n", "]h", gs.next_hunk, { desc = "Next hunk" })