Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update git related mappings #311

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions lua/config/fugitive.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
local keymap = vim.keymap

keymap.set("n", "<leader>gs", "<cmd>Git<cr>", { desc = "Git status" })
keymap.set("n", "<leader>gw", "<cmd>Gwrite<cr>", { desc = "Git add" })
keymap.set("n", "<leader>gc", "<cmd>Git commit<cr>", { desc = "Git commit" })
keymap.set("n", "<leader>gd", "<cmd>Gdiffsplit<cr>", { desc = "Git diff" })
keymap.set("n", "<leader>gpl", "<cmd>Git pull<cr>", { desc = "Git pull" })
keymap.set("n", "<leader>gpu", "<cmd>15 split|term git push<cr>", { desc = "Git push" })
keymap.set("v", "<leader>gb", ":Git blame<cr>", { desc = "Git blame line" })
keymap.set("n", "<leader>gs", "<cmd>Git<cr>", { desc = "Git: show status" })
keymap.set("n", "<leader>gw", "<cmd>Gwrite<cr>", { desc = "Git: add file" })
keymap.set("n", "<leader>gc", "<cmd>Git commit<cr>", { desc = "Git: commit changes" })
keymap.set("n", "<leader>gpl", "<cmd>Git pull<cr>", { desc = "Git: pull changes" })
keymap.set("n", "<leader>gpu", "<cmd>15 split|term git push<cr>", { desc = "Git: push changes" })
keymap.set("v", "<leader>gb", ":Git blame<cr>", { desc = "Git: blame selected line" })

-- convert git to Git in command line mode
vim.fn["utils#Cabbrev"]("git", "Git")

keymap.set("n", "<leader>gnb", function()
vim.ui.input({ prompt = "Enter the new branch nmae" }, function(user_input)
if user_input == nil or user_input == "" then
return
end

local cmd_str = string.format("G checkout -b %s", user_input)
vim.cmd(cmd_str)
end)
end, {
desc = "Git: create new branch",
})

keymap.set("n", "<leader>gf", "<cmd>Git fetch", { desc = "Git: prune branches" })
keymap.set("n", "<leader>gbd", ":Git branch -D ", { desc = "Git: delete branch" })
6 changes: 3 additions & 3 deletions lua/config/git-linker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ keymap.set({ "n", "v" }, "<leader>gl", function()
gitlinker.get_buf_range_url(mode)
end, {
silent = true,
desc = "get git permlink",
desc = "Git: get permlink",
})

keymap.set("n", "<leader>gb", function()
keymap.set("n", "<leader>gbr", function()
gitlinker.get_repo_url({
action_callback = gitlinker.actions.open_in_browser
})
end, {
silent = true,
desc = "browse repo in browser",
desc = "Git: browse repo in browser",
})