From 8e3351c430cf589edb3c0801f2123a923f822d40 Mon Sep 17 00:00:00 2001 From: jdhao Date: Fri, 9 Aug 2024 22:18:39 +0200 Subject: [PATCH] update git related mappings --- lua/config/fugitive.lua | 29 ++++++++++++++++++++++------- lua/config/git-linker.lua | 6 +++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lua/config/fugitive.lua b/lua/config/fugitive.lua index 9aaab97d..8d37cf3f 100644 --- a/lua/config/fugitive.lua +++ b/lua/config/fugitive.lua @@ -1,12 +1,27 @@ local keymap = vim.keymap -keymap.set("n", "gs", "Git", { desc = "Git status" }) -keymap.set("n", "gw", "Gwrite", { desc = "Git add" }) -keymap.set("n", "gc", "Git commit", { desc = "Git commit" }) -keymap.set("n", "gd", "Gdiffsplit", { desc = "Git diff" }) -keymap.set("n", "gpl", "Git pull", { desc = "Git pull" }) -keymap.set("n", "gpu", "15 split|term git push", { desc = "Git push" }) -keymap.set("v", "gb", ":Git blame", { desc = "Git blame line" }) +keymap.set("n", "gs", "Git", { desc = "Git: show status" }) +keymap.set("n", "gw", "Gwrite", { desc = "Git: add file" }) +keymap.set("n", "gc", "Git commit", { desc = "Git: commit changes" }) +keymap.set("n", "gpl", "Git pull", { desc = "Git: pull changes" }) +keymap.set("n", "gpu", "15 split|term git push", { desc = "Git: push changes" }) +keymap.set("v", "gb", ":Git blame", { desc = "Git: blame selected line" }) -- convert git to Git in command line mode vim.fn["utils#Cabbrev"]("git", "Git") + +keymap.set("n", "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", "gf", "Git fetch", { desc = "Git: prune branches" }) +keymap.set("n", "gbd", ":Git branch -D ", { desc = "Git: delete branch" }) diff --git a/lua/config/git-linker.lua b/lua/config/git-linker.lua index 39f5ba21..e3fb3e67 100644 --- a/lua/config/git-linker.lua +++ b/lua/config/git-linker.lua @@ -24,14 +24,14 @@ keymap.set({ "n", "v" }, "gl", function() gitlinker.get_buf_range_url(mode) end, { silent = true, - desc = "get git permlink", + desc = "Git: get permlink", }) -keymap.set("n", "gb", function() +keymap.set("n", "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", })