mirror of
https://github.com/neovim/neovim.git
synced 2026-01-03 09:56:25 +10:00
docs(lua): iInconsistent vim.keymap param name #37026
Problem: vim.keymap.del has 'modes' as it's first argument while vim.keymap.set has 'mode' as it's first argument despite both 'mode' and 'modes' taking in the same type input of String or String[]. Solution: Updated vim.keymap.set docs to refer to it's first argument as 'modes'.
This commit is contained in:
@@ -44,7 +44,7 @@ local keymap = {}
|
||||
--- end)
|
||||
--- ```
|
||||
---
|
||||
---@param mode string|string[] Mode "short-name" (see |nvim_set_keymap()|), or a list thereof.
|
||||
---@param modes 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
|
||||
@@ -53,16 +53,16 @@ local keymap = {}
|
||||
---@see |maparg()|
|
||||
---@see |mapcheck()|
|
||||
---@see |mapset()|
|
||||
function keymap.set(mode, lhs, rhs, opts)
|
||||
vim.validate('mode', mode, { 'string', 'table' })
|
||||
function keymap.set(modes, lhs, rhs, opts)
|
||||
vim.validate('modes', modes, { 'string', 'table' })
|
||||
vim.validate('lhs', lhs, 'string')
|
||||
vim.validate('rhs', rhs, { 'string', 'function' })
|
||||
vim.validate('opts', opts, 'table', true)
|
||||
|
||||
opts = vim.deepcopy(opts or {}, true)
|
||||
|
||||
---@cast mode string[]
|
||||
mode = type(mode) == 'string' and { mode } or mode
|
||||
---@cast modes string[]
|
||||
modes = type(modes) == 'string' and { modes } or modes
|
||||
|
||||
if opts.expr and opts.replace_keycodes ~= false then
|
||||
opts.replace_keycodes = true
|
||||
@@ -85,12 +85,12 @@ function keymap.set(mode, lhs, rhs, opts)
|
||||
if opts.buffer then
|
||||
local bufnr = opts.buffer == true and 0 or opts.buffer --[[@as integer]]
|
||||
opts.buffer = nil ---@type integer?
|
||||
for _, m in ipairs(mode) do
|
||||
for _, m in ipairs(modes) do
|
||||
vim.api.nvim_buf_set_keymap(bufnr, m, lhs, rhs, opts)
|
||||
end
|
||||
else
|
||||
opts.buffer = nil
|
||||
for _, m in ipairs(mode) do
|
||||
for _, m in ipairs(modes) do
|
||||
vim.api.nvim_set_keymap(m, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user