home: vim: git: map keys on start
Instead of mapping those keys when `gitsigns` attaches to a buffer...
This commit is contained in:
parent
80c2c415fb
commit
e073cc900c
|
@ -1,5 +1,6 @@
|
||||||
lua << EOF
|
lua << EOF
|
||||||
local gitsigns = require('gitsigns')
|
local gitsigns = require('gitsigns')
|
||||||
|
local wk = require("which-key")
|
||||||
|
|
||||||
gitsigns.setup({
|
gitsigns.setup({
|
||||||
-- I dislike the full-green sign column when this happens
|
-- I dislike the full-green sign column when this happens
|
||||||
|
@ -9,11 +10,9 @@ gitsigns.setup({
|
||||||
-- Show the blame quickly
|
-- Show the blame quickly
|
||||||
delay = 100,
|
delay = 100,
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
|
||||||
on_attach = function(bufnr)
|
local keys = {
|
||||||
local wk = require("which-key")
|
|
||||||
|
|
||||||
local keys = {
|
|
||||||
-- Navigation
|
-- Navigation
|
||||||
["[c"] = { "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", "Previous hunk/diff", expr = true },
|
["[c"] = { "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", "Previous hunk/diff", expr = true },
|
||||||
["]c"] = { "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", "Next hunk/diff", expr = true },
|
["]c"] = { "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", "Next hunk/diff", expr = true },
|
||||||
|
@ -39,13 +38,13 @@ gitsigns.setup({
|
||||||
["["] = { gitsigns.prev_hunk, "Previous hunk" },
|
["["] = { gitsigns.prev_hunk, "Previous hunk" },
|
||||||
["]"] = { gitsigns.next_hunk, "Next hunk" },
|
["]"] = { gitsigns.next_hunk, "Next hunk" },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local objects = {
|
local objects = {
|
||||||
["ih"] = { gitsigns.select_hunk, "Git hunk" },
|
["ih"] = { gitsigns.select_hunk, "Git hunk" },
|
||||||
}
|
}
|
||||||
|
|
||||||
local visual = {
|
local visual = {
|
||||||
["ih"] = { gitsigns.select_hunk, "Git hunk" },
|
["ih"] = { gitsigns.select_hunk, "Git hunk" },
|
||||||
|
|
||||||
-- Only the actual command can make use of the visual selection...
|
-- Only the actual command can make use of the visual selection...
|
||||||
|
@ -56,11 +55,9 @@ gitsigns.setup({
|
||||||
s = { ":Gitsigns stage_hunk<CR>", "Stage selection" },
|
s = { ":Gitsigns stage_hunk<CR>", "Stage selection" },
|
||||||
u = { ":Gitsigns undo_stage_hunk<CR>", "Undo stage selection" },
|
u = { ":Gitsigns undo_stage_hunk<CR>", "Undo stage selection" },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
wk.register(keys, { buffer = bufnr })
|
wk.register(keys, { buffer = bufnr })
|
||||||
wk.register(objects, { buffer = bufnr, mode = "o" })
|
wk.register(objects, { buffer = bufnr, mode = "o" })
|
||||||
wk.register(visual, { buffer = bufnr, mode = "x" })
|
wk.register(visual, { buffer = bufnr, mode = "x" })
|
||||||
end,
|
|
||||||
})
|
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in a new issue