gitsigns mappings + tweaks

master
spike 2 years ago
parent f31f3649e9
commit e4189180ef

@ -326,10 +326,6 @@ M.general = { --{{{
t = { ["<C-x>"] = { termcodes "<C-\\><C-N>", "escape terminal mode" } },
v = { --{{{
-- ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
-- ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["j"] = { "gj" },
["k"] = { "gk" },
-- yank from cursor to eol to system and primary clipboard
@ -373,6 +369,11 @@ M.general = { --{{{
-- visual exclusive mode (ignore select)
x = { -- {{{
-- ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
-- ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
["j"] = { "gj" },
["k"] = { "gk" },
-- Don't copy the replaced text after pasting in visual mode
-- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste
["p"] = { 'p:let @+=@0<CR>:let @"=@0<CR>', opts = { silent = true } },
@ -702,7 +703,8 @@ M.general = { --{{{
end
end
vim.cmd "Telescope find_files"
end, "FzfLua find files" },
end, "FzfLua find files"
},
["<leader>f."] = { "<cmd> Telescope live_grep <CR>", "telescope live grep" },
["<leader>fw"] = { "<cmd> Telescope grep_string <CR>", "telescope grep cword" },
["<leader>;"] = { "<cmd> Telescope buffers <CR>", "telescope find buffers" },
@ -913,5 +915,33 @@ M.golang = {
["<leader>da"] = { "<cmd> GoDebug -a<CR>", "go debug attach" },
}
}
--
-- git
M.gitsigns = {
plugin = true,
n = {
["<leader>gs"] = { "<cmd> lua require'gitsigns'.stage_hunk()<CR>",
"Git stage hunk",
},
["<leader>gS"] = { "<cmd> lua require'gitsigns'.stage_buffer()<CR>",
"Git stage buffer",
},
["<leader>gR"] = { "<cmd> lua require'gitsigns'.reset_buffer_index()<CR>",
"Git stage buffer",
},
["<leader>gp"] = { "<cmd> lua require'gitsigns'.preview_hunk()<CR>",
"Git stage buffer",
},
["<leader>gu"] = {"<cmd> lua require'gitsigns'.undo_stage_hunk()<CR>",
"Git undo stage hunk",
},
["]h"] = { "<cmd> lua require'gitsigns'.next_hunk()<CR>",
"Git next hunk",
},
["[h"] = { "<cmd> lua require'gitsigns'.prev_hunk()<CR>",
"Git prev hunk",
}
}
}
return M

@ -14,7 +14,7 @@ local colors = {
-- vim.tbl_deep_extend("force", M.ui.hl_add, custom_theme)
M.ui = {
theme = "gruvbox_light",
theme = "monekai",
theme_toggle = { "monekai", "gruvbox_light" },
hl_override = {
Comment = {

@ -0,0 +1,32 @@
local M = {}
local on_attach = function(bufnr)
require("custom.utils").set_plugin_mappings "gitsigns"
end
M.setup = function()
local present, gitsigns = pcall(require, "gitsigns")
if not present then
return
end
require("base46").load_highlight "git"
local options = {
signs = {
add = { hl = "DiffAdd", text = "", numhl = "GitSignsAddNr" },
change = { hl = "DiffChange", text = "", numhl = "GitSignsChangeNr" },
delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" },
topdelete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" },
changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" },
},
on_attach = on_attach,
}
gitsigns.setup(options)
end
return M

@ -328,6 +328,16 @@ return {
}, -- }}}
-- Git
["lewis6991/gitsigns.nvim"] = {
ft = "gitcommit",
setup = function()
require("core.lazy_load").gitsigns()
end,
config = function()
require("custom.plugins.configs.gitsigns").setup()
end,
},
["tpope/vim-fugitive"] = {
cmd = { "G", "Git", "G*" }
},

@ -13,6 +13,7 @@ local M = {}
mapping_info.opts, opts.mode = nil, nil
opts.desc = mapping_info[2]
P(keybind)
vim.keymap.set(mode, keybind, mapping_info[1], opts)
end
end

@ -92,7 +92,10 @@ local options = {
elseif luasnip.expandable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.confirm()
cmp.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = false,
})
else
fallback()
end

@ -106,28 +106,6 @@ M.comment = function()
nvim_comment.setup(options)
end
M.gitsigns = function()
local present, gitsigns = pcall(require, "gitsigns")
if not present then
return
end
require("base46").load_highlight "git"
local options = {
signs = {
add = { hl = "DiffAdd", text = "", numhl = "GitSignsAddNr" },
change = { hl = "DiffChange", text = "", numhl = "GitSignsChangeNr" },
delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" },
topdelete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" },
changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" },
},
}
options = load_override(options, "lewis6991/gitsigns.nvim")
gitsigns.setup(options)
end
M.devicons = function()
local present, devicons = pcall(require, "nvim-web-devicons")

@ -86,17 +86,6 @@ local plugins = {
end,
},
-- git stuff
["lewis6991/gitsigns.nvim"] = {
ft = "gitcommit",
setup = function()
require("core.lazy_load").gitsigns()
end,
config = function()
require("plugins.configs.others").gitsigns()
end,
},
-- lsp stuff
["williamboman/mason.nvim"] = {

Loading…
Cancel
Save