mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat(keys): allow overriding a keys value to vim.NIL
to not add the key
This commit is contained in:
parent
984008f7ae
commit
fdf0332fe1
2 changed files with 51 additions and 50 deletions
|
@ -62,28 +62,28 @@ function M.new(type)
|
|||
return self
|
||||
end
|
||||
|
||||
---@param value string
|
||||
---@param _value string
|
||||
---@protected
|
||||
function M:_add(value) end
|
||||
function M:_add(_value) end
|
||||
|
||||
---@param value string
|
||||
---@param _value string
|
||||
---@protected
|
||||
function M:_del(value) end
|
||||
function M:_del(_value) end
|
||||
|
||||
---@return string
|
||||
function M:key(value)
|
||||
return value
|
||||
---@param plugin LazyPlugin
|
||||
function M:values(plugin)
|
||||
---@type table<string,any>
|
||||
local values = {}
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
for _, value in ipairs(plugin[self.type] or {}) do
|
||||
values[value] = value
|
||||
end
|
||||
return values
|
||||
end
|
||||
|
||||
---@param plugin LazyPlugin
|
||||
function M:add(plugin)
|
||||
local values = {}
|
||||
for _, value in ipairs(plugin[self.type] or {}) do
|
||||
local key = self:key(value)
|
||||
values[key] = value
|
||||
end
|
||||
|
||||
for key, value in pairs(values) do
|
||||
for key, value in pairs(self:values(plugin)) do
|
||||
if not self.active[key] then
|
||||
self.active[key] = {}
|
||||
self:_add(value)
|
||||
|
@ -94,14 +94,7 @@ end
|
|||
|
||||
---@param plugin LazyPlugin
|
||||
function M:del(plugin)
|
||||
local values = {}
|
||||
for _, value in ipairs(plugin[self.type] or {}) do
|
||||
local key = self:key(value)
|
||||
values[key] = value
|
||||
end
|
||||
|
||||
for key, value in pairs(values) do
|
||||
local key = self:key(value)
|
||||
for key, value in pairs(self:values(plugin)) do
|
||||
if self.active[key] and self.active[key][plugin.name] then
|
||||
self.active[key][plugin.name] = nil
|
||||
if vim.tbl_isempty(self.active[key]) then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue