diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-09-25 07:01:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-25 07:01:27 -0700 |
commit | f3b7444e6638095305d86fa96fe0b7407c9b1648 (patch) | |
tree | 04a34092d74f4eaf175867200b23afc152a237c8 /runtime/lua/vim/keymap.lua | |
parent | 069451bb214bd9d97273ac92b37a25054df0f1a8 (diff) | |
download | rneovim-f3b7444e6638095305d86fa96fe0b7407c9b1648.tar.gz rneovim-f3b7444e6638095305d86fa96fe0b7407c9b1648.tar.bz2 rneovim-f3b7444e6638095305d86fa96fe0b7407c9b1648.zip |
refactor(lua): vim.keymap.set tests, docs #30511
Diffstat (limited to 'runtime/lua/vim/keymap.lua')
-rw-r--r-- | runtime/lua/vim/keymap.lua | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua index ec00c56c7a..50ca0d2d0e 100644 --- a/runtime/lua/vim/keymap.lua +++ b/runtime/lua/vim/keymap.lua @@ -15,30 +15,28 @@ local keymap = {} --- (Default: `false`) --- @field remap? boolean ---- Adds a new |mapping|. +--- Defines a |mapping| of |keycodes| to a function or keycodes. +--- --- Examples: --- --- ```lua ---- -- Map to a Lua function: ---- vim.keymap.set('n', 'lhs', function() print("real lua function") end) ---- -- Map to multiple modes: ---- vim.keymap.set({'n', 'v'}, '<leader>lr', vim.lsp.buf.references, { buffer = true }) ---- -- Buffer-local mapping: ---- vim.keymap.set('n', '<leader>w', "<cmd>w<cr>", { silent = true, buffer = 5 }) ---- -- Expr mapping: +--- -- Map "x" to a Lua function: +--- vim.keymap.set('n', 'x', function() print("real lua function") end) +--- -- Map "<leader>x" to multiple modes for the current buffer: +--- vim.keymap.set({'n', 'v'}, '<leader>x', vim.lsp.buf.references, { buffer = true }) +--- -- Map <Tab> to an expression (|:map-<expr>|): --- vim.keymap.set('i', '<Tab>', function() --- return vim.fn.pumvisible() == 1 and "<C-n>" or "<Tab>" --- end, { expr = true }) ---- -- <Plug> mapping: +--- -- Map "[%%" to a <Plug> mapping: --- vim.keymap.set('n', '[%%', '<Plug>(MatchitNormalMultiBackward)') --- ``` --- ----@param mode string|string[] Mode short-name, see |nvim_set_keymap()|. ---- Can also be list of modes to create mapping on multiple modes. +---@param mode string|string[] Mode "short-name" (see |nvim_set_keymap()|), or a list thereof. ---@param lhs string Left-hand side |{lhs}| of the mapping. ---@param rhs string|function Right-hand side |{rhs}| of the mapping, can be a Lua function. ---- ---@param opts? vim.keymap.set.Opts +--- ---@see |nvim_set_keymap()| ---@see |maparg()| ---@see |mapcheck()| |