Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(keys): use allowlist for valid opts #1792

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lua/lazy/core/handler/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ local Util = require("lazy.core.util")
---@class LazyKeysHandler:LazyHandler
local M = {}

local skip = { mode = true, id = true, ft = true, rhs = true, lhs = true }
local valid = {
remap = true,
noremap = true,
buffer = true,
silent = true,
nowait = true,
expr = true,
unique = true,
script = true,
desc = true,
replace_keycodes = true,
}

---@param value string|LazyKeysSpec
---@param mode? string
Expand Down Expand Up @@ -94,7 +105,7 @@ function M.opts(keys)
local opts = {} ---@type LazyKeysBase
---@diagnostic disable-next-line: no-unknown
for k, v in pairs(keys) do
if type(k) ~= "number" and not skip[k] then
if type(k) ~= "number" and valid[k] then
---@diagnostic disable-next-line: no-unknown
opts[k] = v
end
Expand Down
Loading