From 52335f09c0bcf253d50b092bb984705335619cfc Mon Sep 17 00:00:00 2001 From: Andy Teijelo Date: Wed, 9 Nov 2022 21:55:49 -0500 Subject: [PATCH] Adding whichkey --- init.lua | 1 + lua/user/gitsigns.lua | 14 +++++++------- lua/user/keymaps.lua | 18 ++++++++++++++++++ lua/user/plugins.lua | 1 + 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 2e691c6..efb10dc 100644 --- a/init.lua +++ b/init.lua @@ -25,3 +25,4 @@ require "user.dap" require "user.exrc" require "user.fidget" +require "user.whichkey" diff --git a/lua/user/gitsigns.lua b/lua/user/gitsigns.lua index 2278544..9323298 100644 --- a/lua/user/gitsigns.lua +++ b/lua/user/gitsigns.lua @@ -33,11 +33,11 @@ gitsigns.setup { row = 0, col = 1, }, - on_attach = function (bufnr) - local gs = package.loaded.gitsigns - local opts = { buffer=bufnr, silent=true } - vim.keymap.set('n', 'hp', gs.preview_hunk, opts) - vim.keymap.set('n', 'hb', function() gs.blame_line{full=false} end, opts) - vim.keymap.set('n', 'hB', function() gs.blame_line{full=true} end, opts) - end + -- on_attach = function (bufnr) + -- local gs = package.loaded.gitsigns + -- local opts = { buffer=bufnr, silent=true } + -- vim.keymap.set('n', 'hp', gs.preview_hunk, opts) + -- vim.keymap.set('n', 'hb', function() gs.blame_line{full=false} end, opts) + -- vim.keymap.set('n', 'hB', function() gs.blame_line{full=true} end, opts) + -- end } diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua index 5e0e759..3c1cb82 100644 --- a/lua/user/keymaps.lua +++ b/lua/user/keymaps.lua @@ -123,3 +123,21 @@ keymap("i", "", "", opts) keymap("i", "", "", opts) keymap("i", "", "gj", opts) keymap("i", "", "gk", opts) + +-- gitsigns +-- vim.keymap.set('n', 'hp', 'Gitsigns preview_hunk', opts) +-- vim.keymap.set('n', 'hb', function() gs.blame_line{full=false} end, opts) +-- vim.keymap.set('n', 'hB', function() gs.blame_line{full=true} end, opts) + +local wk = require("which-key") +local gs = require("gitsigns") +wk.register({ + g = { + name = "gitsigns", + p = { "Gitsigns preview_hunk", "Preview hunk" }, + b = { function() gs.blame_line{full=false} end, "Blame line (short)" }, + B = { function() gs.blame_line{full=true} end, "Blame line (full)" } + }, + prefix = "" +}) + diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua index f4290f7..7f7ff61 100644 --- a/lua/user/plugins.lua +++ b/lua/user/plugins.lua @@ -117,6 +117,7 @@ return packer.startup(function(use) use { "mg979/vim-visual-multi" } use { 'vala-lang/vala.vim' } + use { 'folke/which-key.nvim' } -- Automatically set up your configuration after cloning packer.nvim -- Put this at the end after all plugins