feat: lazy field for lazy-loading via trigger_load only (#105)

This commit is contained in:
Marc Jakobi
2024-10-21 17:28:23 +02:00
committed by GitHub
parent 2692693947
commit a7b445fd34
6 changed files with 46 additions and 1 deletions
+1
View File
@@ -6,6 +6,7 @@ local handlers = {
ft = require("lz.n.handler.ft"),
keys = require("lz.n.handler.keys"),
colorscheme = require("lz.n.handler.colorscheme"),
lazy = require("lz.n.handler.lazy"),
}
---@param name string
+32
View File
@@ -0,0 +1,32 @@
---A handler for plugins that have `lazy` set to true without any other lazy-loading mechanisms configured.
---@class lz.n.LazyHandler: lz.n.Handler
---@type lz.n.handler.State
local state = require("lz.n.handler.state").new()
local M = {
spec_field = "lazy",
}
---@param name string
---@return lz.n.Plugin?
function M.lookup(name)
return state.lookup_plugin(name)
end
---@param name string
function M.del(name)
state.del(name, function(cmd)
pcall(vim.api.nvim_del_user_command, cmd)
end)
end
---@param plugin lz.n.Plugin
function M.add(plugin)
if not plugin.lazy then
return
end
state.insert(plugin)
end
return M
+1
View File
@@ -26,6 +26,7 @@
---@field keys? lz.n.Keys[]
---@field cmd? string[]
---@field colorscheme? string[]
---@field lazy? boolean
---@class lz.n.PluginSpecHandlers
---