How can I port map
commands in my vimrc file to Neovim lua configuration? For example:
nmap <silent> <F2> <Plug>(lcn-rename)
You use vim.api.nvim_set_keymap
vim.api.nvim_set_keymap(mode, keys, mapping, options)
So to port
nmap <silent> <F2> <Plug>(lcn-rename)
It would look like
vim.api.nvim_set_keymap('n', '<F2>', "<Plug>(lcn-rename')", { noremap = true, silent = true });
Alternatively you can create convenience functions,
function map(mode, shortcut, command)
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
end
function nmap(shortcut, command)
map('n', shortcut, command)
end
function imap(shortcut, command)
map('i', shortcut, command)
end