generated from mrcjkb/nvim-lua-nix-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
lz.n.txt
257 lines (179 loc) · 11.4 KB
/
lz.n.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
==============================================================================
*lz.n*
A dead simple lazy-loading Lua library for Neovim plugins.
It is intended to be used
- by users of plugin managers that don't provide a convenient API for lazy-loading.
- by plugin managers, to provide a convenient API for lazy-loading.
==============================================================================
Table of Contents *lz.n.contents*
········································································ |lz.n|
lz.n Lua API ························································ |lz.n.api|
lz.n type definitions ············································· |lz.n.types|
Safe state management for handlers ························ |lz.n.handler.state|
==============================================================================
lz.n Lua API *lz.n.api*
M.trigger_load() *M.trigger_load*
The function provides two overloads, each suited for different use cases:
@overload fun(plugin: lz.n.Plugin)
**Stateless version:**
- Intended for: Use by a `lz.n.Handler`
- Description: This version should be used when working with `lz.n.Handler`
instances to maintain referential transparency.
Each handler has full authority over its internal state, ensuring it
remains isolated and unaffected by external influences,
thereby preventing multiple sources of truth.
- Note: If loading multiple plugins simultaneously,
handlers should iterate over |vim.deepcopy| of the plugins,
verifying they are still pending before each `trigger_load` call.
This practice allows for safe invocation of the stateful `trigger_load`
in `before` and `after` hooks.
@overload fun(plugins: string | string[], opts?: lz.n.lookup.Opts): string[]
**Stateful version:**
- Returns: A list of plugin names that were skipped
(empty if all plugins were loaded).
- Intended for: Scenarios where handler state is unknown or inaccessible,
such as in `before` or `after` hooks.
- Description: This version allows you to load plugins by name.
It searches through the handlers, querying their `lookup` functions
to identify an appropriate plugin, and returns the first match.
You can fine-tune the search process by providing a [`lz.n.lookup.Opts` table](#lookup).
M.load() *M.load*
@overload fun(spec: lz.n.Spec)
Register a list with your plugin specs or a single plugin spec to be lazy-loaded.
@overload fun(import: string)
Register a Lua module name that contains your plugin spec(s) to be lazy-loaded.
M.lookup({name}, {opts?}) *M.lookup*
Lookup a plugin that is pending to be loaded by name.
Parameters: ~
{name} (string)
{opts?} (lz.n.lookup.Opts) @return lz.n.Plugin?
lz.n.lookup.Opts *lz.n.lookup.Opts*
Fields: ~
{filter} (string|string[])
The handlers to include in the search (filtered by `spec_field`)
In case of multiple filters, the order of the filter list
determines the order in which handlers' `lookup` functions are called.
M.register_handler({handler}) *M.register_handler*
Register a custom handler.
Parameters: ~
{handler} (lz.n.Handler)
Returns: ~
(boolean) success
==============================================================================
lz.n type definitions *lz.n.types*
lz.n.PluginBase *lz.n.PluginBase*
Fields: ~
{enabled?} (boolean|fun():boolean)
Whether to enable this plugin. Useful to disable plugins under certain conditions.
{priority?} (number)
Only useful for lazy=false plugins to force loading certain plugins first.
Default priority is 50
{load?} (fun(name:string))
Set this to override the `load` function for an individual plugin.
Defaults to `vim.g.lz_n.load()`, see |lz.n.Config|.
lz.n.Event *lz.n.Event*
Type: ~
{id:string,event:string[]|string,pattern?:string[]|string}
lz.n.EventSpec *lz.n.EventSpec*
Type: ~
string|{event?:string|string[],pattern?:string|string[]}|string[]
lz.n.PluginHooks *lz.n.PluginHooks*
Fields: ~
{beforeAll?} (fun(self:lz.n.Plugin)) Will be run before loading any plugins
{before?} (fun(self:lz.n.Plugin)) Will be run before loading this plugin
{after?} (fun(self:lz.n.Plugin)) Will be executed after loading this plugin
lz.n.PluginHandlers *lz.n.PluginHandlers*
Fields: ~
{event?} (lz.n.Event[])
{keys?} (lz.n.Keys[])
{cmd?} (string[])
{colorscheme?} (string[])
{lazy?} (boolean)
lz.n.PluginSpecHandlers *lz.n.PluginSpecHandlers*
Fields: ~
{event?} (string|lz.n.EventSpec[])
Load a plugin on one or more |autocmd-events|.
{cmd?} (string[]|string)
Load a plugin on one or more |user-commands|.
{ft?} (string[]|string)
Load a plugin on one or more |FileType| events.
{keys?} (string|string[]|lz.n.KeysSpec[])
Load a plugin on one or more |key-mapping|s.
{colorscheme?} (string[]|string)
Load a plugin on one or more |colorscheme| events.
lz.n.KeysBase : vim.keymap.set.Opts *lz.n.KeysBase*
Fields: ~
{desc?} (string)
{noremap?} (boolean)
{remap?} (boolean)
{expr?} (boolean)
{nowait?} (boolean)
{ft?} (string|string[])
lz.n.KeysSpec : lz.n.KeysBase *lz.n.KeysSpec*
Fields: ~
{1} (string) lhs
{2?} (string|fun()|false) rhs
{mode?} (string|string[])
lz.n.Keys : lz.n.KeysBase *lz.n.Keys*
Fields: ~
{lhs} (string) lhs
{rhs?} (string|fun()) rhs
{mode?} (string)
{id} (string)
{name} (string)
*lz.n.Plugin*
lz.n.Plugin : lz.n.PluginBase, lz.n.PluginHandlers, lz.n.PluginHooks
Fields: ~
{name} (string)
The plugin name (not its main module), e.g. "sweetie.nvim"
{lazy?} (boolean)
Whether to lazy-load this plugin. Defaults to `false`.
*lz.n.PluginSpec*
lz.n.PluginSpec : lz.n.PluginBase, lz.n.PluginSpecHandlers, lz.n.PluginHooks
Fields: ~
{1} (string)
The plugin name (not its main module), e.g. "sweetie.nvim"
lz.n.SpecImport *lz.n.SpecImport*
Fields: ~
{import} (string) spec module to import
{enabled?} (boolean|fun():boolean)
lz.n.Spec *lz.n.Spec*
Type: ~
lz.n.PluginSpec|lz.n.SpecImport|lz.n.Spec[]
lz.n.Config *lz.n.Config*
Fields: ~
{load?} (fun(name:string))
Callback to load a plugin.
Takes the plugin name (not the module name). Defaults to |packadd| if not set.
lz.n.Handler *lz.n.Handler*
Fields: ~
{spec_field} (string)
The |lz.n.PluginSpec| field used to configure this handler.
{add} (fun(plugin:lz.n.Plugin))
Add a plugin to this handler.
{del} (fun(name:string))
Remove a plugin from this handler by name.
{lookup} (fun(name:string):lz.n.Plugin)
Lookup a plugin by name.
==============================================================================
Safe state management for handlers *lz.n.handler.state*
This module is to be used by |lz.n.Handler| implementations.
It provides an API for safely managing handler state,
ensuring that `trigger_load` can be called in plugin hooks.
state.new() *state.new*
Returns: ~
(lz.n.handler.State)
lz.n.handler.State *lz.n.handler.State*
Fields: ~
{insert} (fun(key:string,plugin:lz.n.Plugin)|fun(plugin:lz.n.Plugin))
Insert a plugin (optionally, by key).
{del} (fun(plugin_name:string,callback?:fun(key:string)))
Remove a plugin by its name.
{has_pending_plugins} (fun(key?:string):boolean)
Check if there are pending plugins (optionally, by key)
{lookup_plugin} (fun(plugin_name:string):lz.n.Plugin|nil)
Lookup a plugin by its name.
{each_pending} (fun(key:string,callback:fun(plugin:lz.n.Plugin)):string[]|fun(callback:fun(plugin:lz.n.Plugin)):string[])
Safely apply a callback to all pending plugins
(optionally, by key).
vim:tw=78:ts=8:noet:ft=help:norl: