mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
feat(lua): add vim.keymap
This introduces two new functions `vim.keymap.set` & `vim.keymap.del`
differences compared to regular set_keymap:
- remap is used as opposite of noremap. By default it's true for <Plug> keymaps and false for others.
- rhs can be lua function.
- mode can be a list of modes.
- replace_keycodes option for lua function expr maps. (Default: true)
- handles buffer specific keymaps
Examples:
```lua
vim.keymap.set('n', 'asdf', function() print("real lua function") end)
vim.keymap.set({'n', 'v'}, '<leader>lr', vim.lsp.buf.references, {buffer=true})
vim.keymap.set('n', '<leader>w', "<cmd>w<cr>", {silent = true, buffer = 5 })
vim.keymap.set('i', '<Tab>', function()
return vim.fn.pumvisible() == 1 and "<C-n>" or "<Tab>"
end, {expr = true})
vim.keymap.set('n', '[%', '<Plug>(MatchitNormalMultiBackward)')
vim.keymap.del('n', 'asdf')
vim.keymap.del({'n', 'i', 'v'}, '<leader>w', {buffer = 5 })
```
This commit is contained in:
@@ -129,6 +129,7 @@ CONFIG = {
|
||||
'uri.lua',
|
||||
'ui.lua',
|
||||
'filetype.lua',
|
||||
'keymap.lua',
|
||||
],
|
||||
'files': ' '.join([
|
||||
os.path.join(base_dir, 'src/nvim/lua/vim.lua'),
|
||||
@@ -136,6 +137,7 @@ CONFIG = {
|
||||
os.path.join(base_dir, 'runtime/lua/vim/uri.lua'),
|
||||
os.path.join(base_dir, 'runtime/lua/vim/ui.lua'),
|
||||
os.path.join(base_dir, 'runtime/lua/vim/filetype.lua'),
|
||||
os.path.join(base_dir, 'runtime/lua/vim/keymap.lua'),
|
||||
]),
|
||||
'file_patterns': '*.lua',
|
||||
'fn_name_prefix': '',
|
||||
@@ -151,6 +153,7 @@ CONFIG = {
|
||||
'uri': 'vim',
|
||||
'ui': 'vim.ui',
|
||||
'filetype': 'vim.filetype',
|
||||
'keymap': 'vim.keymap',
|
||||
},
|
||||
'append_only': [
|
||||
'shared.lua',
|
||||
|
||||
Reference in New Issue
Block a user