Skip to content

Commit fe1596e

Browse files
committed
docs: new public functions
1 parent 49a02ad commit fe1596e

File tree

1 file changed

+80
-13
lines changed

1 file changed

+80
-13
lines changed

doc/libmodal.txt

Lines changed: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ VARIABLES *libmodal-usage-variable
105105
`nil`
106106

107107
See also: ~
108-
|g:| For more information about global variables.
109-
|vim.g| For info about accessing |g:| from lua.
108+
|g:| For more information about global variables.
109+
|vim.g| For info about accessing |g:| from lua.
110110

111111
--------------------------------------------------------------------------------
112112
FUNCTIONS *libmodal-usage-functions*
@@ -128,7 +128,7 @@ FUNCTIONS *libmodal-usage-function
128128
To take input on a line-by-line basis, see |libmodal-prompt|.
129129

130130
Note: `libmodal.mode.enter()`/`libmodal#Enter()` may be called from inside
131-
itself. See |libmodal-examples-submodes| for an example.
131+
itself. See |libmodal-examples| for an example.
132132

133133
Parameters: ~
134134
{name} The name of the mode (e.g. |INSERT|).
@@ -190,16 +190,15 @@ FUNCTIONS *libmodal-usage-function
190190
- If |v:true|/`true`, then <Esc> is ignored unless specified by
191191
the user. In such cases, the user should set the
192192
`g:`{name}`ModeExit` variable to `true` when exiting is
193-
desired. See |libmodal-examples-supress-exit|.
193+
desired. See |libmodal-examples|.
194194

195195
See also: ~
196-
|lua-eval| For type conversions between Vimscript to
197-
|Lua|.
198-
|libmodal-examples-mode| For examples of this function.
196+
|lua-eval| For type conversions between Vimscript to |Lua|.
197+
|libmodal-examples| For examples of this function.
199198

200199

201-
*libmodal-layer* *libmodal.layer.enter()*
202-
`libmodal.layer`.enter({keymap} [, {exit_char}])
200+
*libmodal-layer* *libmodal.layer*
201+
`libmodal.layer`.enter({keymap} [, {exit_char}]) *libmodal.layer.enter()*
203202

204203
While a |libmodal-mode| ignores behavior that has not been explicitly
205204
defined, a |libmodal-layer| allows unrecognized |input| to be passed back
@@ -233,8 +232,76 @@ FUNCTIONS *libmodal-usage-function
233232
{exit_char} is provided.
234233

235234
See also: ~
236-
|libmodal-examples-layers| For an example.
237-
|nvim_set_keymap()| For more information about {keymap}.
235+
|libmodal-examples| For an example.
236+
|vim.keymap.set()| For more information about `opts`.
237+
238+
`libmodal.layer`.new({keymap}) *libmodal.layer.new()*
239+
240+
See |libmodal.layer.enter()| for more information. This function only
241+
differs from |libmodal.layer.enter()| in that instead of entering the layer
242+
immediately, it returns a |libmodal.Layer| object for you to manipulate.
243+
244+
Parameters: ~
245+
{keymap} The keymap for the layer. General template is this: >
246+
{
247+
[<mode>] = {
248+
[<lhs>] = {
249+
rhs = <rhs>,
250+
<opts>
251+
},
252+
253+
},
254+
255+
}
256+
< Where {mode}, {lhs}, {rhs}, and {opts} are the same as in
257+
|vim.keymap.set()| (except you should not use multiple `<mode>` at
258+
one time, despite |vim.keymap.set()| supporting it).
259+
260+
Return: ~
261+
- A |libmodal.Layer| object.
262+
263+
See also: ~
264+
|libmodal-layer| For more information about layers.
265+
|libmodal-examples| For an example.
266+
|vim.keymap.set()| For more information about `opts`.
267+
268+
*libmodal-Layer* *libmodal.Layer*
269+
`libmodal.Layer`:enter() *libmodal.Layer:enter()*
270+
271+
Applies the {keymap} which was provided by |libmodal.layer.new|. These two
272+
code snippets are equivalent: >
273+
local libmodal = require 'libmodal'
274+
275+
-- enter a layer directly
276+
libmodal.layer.enter({n = gg = {rhs = 'G'}})
277+
278+
-- enter a layer manually
279+
local layer = libmodal.layer.new({n = gg = {rhs = 'G'}})
280+
layer:enter()
281+
<
282+
See also: ~
283+
|libmodal.mode.enter| A shortcut to access this function.
284+
|libmodal.mode.new| How to create a |libmodal.Layer|
285+
286+
`libmodal.Layer`:map({mode}, {lhs}, {rhs}, {opts}) *libmodal.Layer:map()*
287+
288+
{mode}, {lhs}, {rhs}, and {opts} are the same as in |vim.keymap.set()|
289+
except that a {mode} table is not supported.
290+
291+
See also: ~
292+
|libmodal-examples| For an example.
293+
|vim.keymap.set()| For information about the args.
294+
295+
`libmodal.Layer`:unmap({mode}, {lhs}) *libmodal.Layer:unmap()*
296+
297+
{mode} and {lhs} are the same as in |vim.keymap.del()| except that a {mode}
298+
table is not supported.
299+
300+
Note: this function cannot be called until after |libmodal.Layer:enter()|
301+
302+
See also: ~
303+
|libmodal-examples| For an example.
304+
|vim.keymap.del()| For information about the args.
238305

239306
*libmodal-prompt* *libmodal#Prompt()* *libmodal.prompt.enter()*
240307
`libmodal.prompt`.enter({name}, {instruction} [, {completions}])
@@ -306,8 +373,8 @@ FUNCTIONS *libmodal-usage-function
306373

307374

308375
See also: ~
309-
|lua-eval| For type conversions between Vimscript to |Lua|.
310-
|libmodal-examples-prompt| For examples of this function.
376+
|lua-eval| For type conversions between Vimscript to |Lua|.
377+
|libmodal-examples| For examples of this function.
311378

312379
================================================================================
313380
3. Examples *libmodal-examples*

0 commit comments

Comments
 (0)