don't fail keymaps if plugins aren't installed

This commit is contained in:
Andy Teijelo 2022-11-10 11:01:12 -05:00
parent 9bad8de707
commit eb0dd08f70

View file

@ -129,9 +129,19 @@ keymap("i", "<M-k>", "<C-o>gk", opts)
-- vim.keymap.set('n', '<Leader>hb', function() gs.blame_line{full=false} end, opts) -- vim.keymap.set('n', '<Leader>hb', function() gs.blame_line{full=false} end, opts)
-- vim.keymap.set('n', '<Leader>hB', function() gs.blame_line{full=true} end, opts) -- vim.keymap.set('n', '<Leader>hB', function() gs.blame_line{full=true} end, opts)
local wk = require("which-key") local function otherkeymaps()
local gs = require("gitsigns") local ok
wk.register({ local wk
local gs
ok, wk = pcall(require, "which-key")
if not ok then
return
end
ok, gs = pcall(require, "gitsigns")
if not ok then
return
end
wk.register({
g = { g = {
name = "gitsigns", name = "gitsigns",
p = { "<cmd>Gitsigns preview_hunk<cr>", "Preview hunk" }, p = { "<cmd>Gitsigns preview_hunk<cr>", "Preview hunk" },
@ -139,5 +149,7 @@ wk.register({
B = { function() gs.blame_line{full=true} end, "Blame line (full)" } B = { function() gs.blame_line{full=true} end, "Blame line (full)" }
}, },
prefix = "<leader>" prefix = "<leader>"
}) })
end
otherkeymaps()