From bba7ad4bc1858e9938554e46472899dbb784ed78 Mon Sep 17 00:00:00 2001 From: Amanda Graven Date: Fri, 17 Jun 2022 09:54:49 +0200 Subject: [PATCH] Add which-key safeguard --- init.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index b7778f0..6ed6827 100644 --- a/init.lua +++ b/init.lua @@ -75,14 +75,20 @@ if fn.executable('rg') then end -- Convenience keybindings -require'which-key'.register{['!'] = {'copen', 'Quickfix window'}} -require'which-key'.register{[''] = {'set number! relativenumber!', 'Toggle relative numbers'}} -require'which-key'.register{[''] = {'set number!', 'Toggle line numbers'}} +do + -- which-key might not be available yet + local ok, which_key = pcall(require, 'which-key') + if ok then + which_key.register{['!'] = {'copen', 'Quickfix window'}} + which_key.register{[''] = {'set number! relativenumber!', 'Toggle relative numbers'}} + which_key.register{[''] = {'set number!', 'Toggle line numbers'}} -require'which-key'.register{[''] = {'h', 'Go to the left window'}} -require'which-key'.register{[''] = {'l', 'Go to the right window'}} -require'which-key'.register{[''] = {'n', 'Go to the up window'}} -require'which-key'.register{[''] = {'e', 'Go to the down window'}} + which_key.register{[''] = {'h', 'Go to the left window'}} + which_key.register{[''] = {'l', 'Go to the right window'}} + which_key.register{[''] = {'n', 'Go to the up window'}} + which_key.register{[''] = {'e', 'Go to the down window'}} + end +end -- Do workman remappings noremap('', 'n', 'gj')