mirror of
https://github.com/zoriya/lz.n.git
synced 2026-06-02 10:55:23 +00:00
feat: lazy field for lazy-loading via trigger_load only (#105)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -26,6 +26,7 @@
|
||||
---@field keys? lz.n.Keys[]
|
||||
---@field cmd? string[]
|
||||
---@field colorscheme? string[]
|
||||
---@field lazy? boolean
|
||||
|
||||
---@class lz.n.PluginSpecHandlers
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user