From 38a9541939d6255937f3960c380edaa996d0c23e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 27 Dec 2022 08:30:28 +0100 Subject: [PATCH] style(plugin): improved types a bit, but sumneko still can't handle them since they're recursive --- lua/lazy/core/plugin.lua | 48 -------------------------------- lua/lazy/types.lua | 60 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 48 deletions(-) create mode 100644 lua/lazy/types.lua diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index fff2b53..96c0b6c 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -5,54 +5,6 @@ local Cache = require("lazy.core.cache") local M = {} ----@alias LazyPluginKind "normal"|"clean" - ----@class LazyPluginState ----@field loaded? {[string]:string}|{time:number} ----@field installed boolean ----@field tasks? LazyTask[] ----@field dirty? boolean ----@field updated? {from:string, to:string} ----@field is_local boolean ----@field has_updates? boolean ----@field cloned? boolean ----@field kind? LazyPluginKind ----@field dep? boolean True if this plugin is only in the spec as a dependency ----@field cond? boolean - ----@class LazyPluginHooks ----@field init? fun(LazyPlugin) Will always be run ----@field config? fun(LazyPlugin)|true|table Will be executed when loading the plugin ----@field build? string|fun(LazyPlugin)|(string|fun(LazyPlugin))[] - ----@class LazyPluginHandlers: table ----@field event? string[] ----@field cmd? string[] ----@field ft? string[] ----@field keys? string[] ----@field module? false - ----@class LazyPluginRef ----@field branch? string ----@field tag? string ----@field commit? string ----@field version? string ----@field pin? boolean - ----@class LazyPlugin: LazyPluginHandlers,LazyPluginHooks,LazyPluginRef ----@field [1] string? ----@field name string display name and name used for plugin config files ----@field url string? ----@field dir string ----@field enabled? boolean|(fun():boolean) ----@field cond? boolean|(fun():boolean) ----@field lazy? boolean ----@field dev? boolean If set, then link to the respective folder under your ~/projects ----@field dependencies? string[] ----@field _ LazyPluginState - ----@alias LazySpec string|LazyPlugin|LazyPlugin[]|{dependencies:LazySpec} - ---@class LazySpecLoader ---@field plugins table ---@field errors string[] diff --git a/lua/lazy/types.lua b/lua/lazy/types.lua new file mode 100644 index 0000000..32feaad --- /dev/null +++ b/lua/lazy/types.lua @@ -0,0 +1,60 @@ + +---@alias LazyPluginKind "normal"|"clean" + +---@class LazyPluginState +---@field loaded? {[string]:string}|{time:number} +---@field installed boolean +---@field tasks? LazyTask[] +---@field dirty? boolean +---@field updated? {from:string, to:string} +---@field is_local boolean +---@field has_updates? boolean +---@field cloned? boolean +---@field kind? LazyPluginKind +---@field dep? boolean True if this plugin is only in the spec as a dependency +---@field cond? boolean + +---@class LazyPluginHooks +---@field init? fun(LazyPlugin) Will always be run +---@field config? fun(LazyPlugin)|true|table Will be executed when loading the plugin +---@field build? string|fun(LazyPlugin)|(string|fun(LazyPlugin))[] + +---@class LazyPluginHandlers +---@field event? string[] +---@field cmd? string[] +---@field ft? string[] +---@field keys? string[] +---@field module? false + +---@class LazyPluginRef +---@field branch? string +---@field tag? string +---@field commit? string +---@field version? string +---@field pin? boolean + +---@class LazyPluginBase +---@field [1] string? +---@field name string display name and name used for plugin config files +---@field url string? +---@field dir string +---@field enabled? boolean|(fun():boolean) +---@field cond? boolean|(fun():boolean) +---@field lazy? boolean +---@field dev? boolean If set, then link to the respective folder under your ~/projects + +---@class LazyPlugin: LazyPluginBase,LazyPluginHandlers,LazyPluginHooks,LazyPluginRef +---@field dependencies? string[] +---@field _ LazyPluginState + +---@class LazyPluginSpecHandlers +---@field event? string[]|string +---@field cmd? string[]|string +---@field ft? string[]|string +---@field keys? string|string[]|LazyKeys[] +---@field module? false + +---@class LazyPluginSpec: LazyPluginBase,LazyPluginSpecHandlers,LazyPluginHooks,LazyPluginRef +---@field dependencies? string|string[]|LazyPluginSpec[] + +---@alias LazySpec string|string[]|LazyPluginSpec[]|LazyPluginSpec[][]