From bef68ba266038b94a532ce76e315dd71089939f3 Mon Sep 17 00:00:00 2001 From: Bryan Turns <95263942+BryanTurns@users.noreply.github.com> Date: Sat, 20 Dec 2025 18:26:44 -0600 Subject: 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'. --- runtime/lua/vim/keymap.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'runtime/lua/vim/keymap.lua') diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua index 0c40abadfc..9273ebf2f4 100644 --- a/runtime/lua/vim/keymap.lua +++ b/runtime/lua/vim/keymap.lua @@ -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 -- cgit