Another Generic Keymap Plugin For Neovim
use {
'saadparwaiz1/keymap.nvim'
}
-- map for normal with mode with default options (silent and noremap)
keymap.map('K', vim.lsp.buf.hover)
-- map for a different mode/options
keymap.map('K', vim.lsp.buf.hover, {mode='i', noremap=false, expr=true})
-- map for various modes
keymap.map('K', vim.lsp.buf.hover, {mode={'i', 'n'}, noremap=false, expr=true})
-- buffer local map by default current buffer
keymap.map('K', vim.lsp.buf.hover, {buffer=0})
-- buffer local map for specific buffer
keymap.map('K', vim.lsp.buf.hover, {buffer=40})
-- Delete Keymap K from insert mode
keymap.del('K', 'i')
-- Delete Keymap K from insert and normal mode
keymap.del('K', {'i', 'n'})
-- Delete buffer local keymap
keymap.del'K', 'i', {buffer=0})
-- same opts as keymap.map_local
keymap.tmp('K', vim.lsp.buf.hover)
-- this keymap can then be reverted to it's orignal mapping as follows
-- second parameter is optional and defaults to 'n' for normal mode
keymap.revert('K')
keymaps = {
{
'K',
vim.lsp.buf.hover,
silent = false,
noremap = false
},
{
'jk',
'<cmd>echo mapped for both insert and normal<CR>',
mode = {'i', 'n'}
}
}
-- first argument is Keymaps
-- second argument are default options for all maps in dicts
-- The second argument is optional and defaults to {noremap=true, silent=true}
-- override options for specific keymaps within the table as shown
keymap.maps(keymaps, {noremap=true, silent=true})