Remove `name`

pull/3/head release/0.6.0
Iron-E 4 years ago
parent b4eef027f5
commit 85214c7487
No known key found for this signature in database
GPG Key ID: 19B71B7B7B021D22

@ -780,7 +780,7 @@ FUNCTIONS *libmodal-lua-Layer-functions*
Example: ~
>
local libmodal = require('libmodal')
local layer = libmodal.Layer.new('FOO', {
local layer = libmodal.Layer.new({
['n'] = {
['gg'] = {
['rhs'] = G
@ -814,7 +814,7 @@ FUNCTIONS *libmodal-lua-Layer-functions*
Example: ~
>
local libmodal = require('libmodal')
local layer = libmodal.Layer.new('FOO', {
local layer = libmodal.Layer.new({
['n'] = {
['gg'] = {
['rhs'] = G
@ -850,7 +850,7 @@ FUNCTIONS *libmodal-lua-Layer-functions*
Example: ~
>
local libmodal = require('libmodal')
local layer = libmodal.Layer.new('FOO', {
local layer = libmodal.Layer.new({
['n'] = {
['gg'] = {
['rhs'] = G
@ -888,7 +888,7 @@ FUNCTIONS *libmodal-lua-Layer-functions*
Example: ~
>
local libmodal = require('libmodal')
local layer = libmodal.Layer.new('FOO', {
local layer = libmodal.Layer.new({
['n'] = {
['gg'] = {
['rhs'] = G
@ -910,29 +910,18 @@ FUNCTIONS *libmodal-lua-Layer-functions*
See also: ~
|libmodal-lua-Layer.enter()| How to enter the `Layer`.
`Layer`.new() *libmodal-lua-Layer.new()*
`Layer`.new({keymap}) *libmodal-lua-Layer.new()*
Create a new `Layer` for `mappings`.
Parameters: ~
{name} The name of the `Layer`.
{mappings} The list of |map|pings to replace.
Example: ~
>
local libmodal = require('libmodal')
local layer = libmodal.Layer.new('FOO', {
['n'] = {
['gg'] = {
['rhs'] = G
}
}
})
{keymap} The list of |map|pings to replace.
Returns: ~
* A new `Layer`.
<
See also: ~
|libmodal-layer| For more information about the parameters.
==============================================================================
7. `libmodal.Mode` *libmodal-lua-Mode*

@ -176,7 +176,7 @@ FUNCTIONS *libmodal-usage-functions*
|libmodal-examples-mode| For examples of this function.
`libmodal.layer`.enter({name}, {keymap}) *libmodal-layer* *libmodal.layer.enter()*
`libmodal.layer`.enter({keymap}) *libmodal-layer* *libmodal.layer.enter()*
While a |libmodal-mode| ignores behavior that has not been explicitly
defined, a |libmodal-layer| allows unrecognized |input| to be passed back
@ -187,14 +187,27 @@ FUNCTIONS *libmodal-usage-functions*
overwritten.
Parameters: ~
{name} The name of the layer.
{keymap} The keymap for the layer.
{keymap} The keymap for the layer. General template is this: >
{
[<mode>] = {
[<lhs>] = {
['rhs'] = <rhs>,
<opts>
},
},
}
< Where {mode}, {lhs}, {rhs}, and {opts} are the same as in
|nvim_set_keymap()|
Return: ~
* The `function` used to undo changes made by the layer.
See also: ~
|libmodal-examples-layers| For an example.
|nvim_set_keymap()| For more information about {keymap}.
*libmodal-prompt* *libmodal#Prompt()* *libmodal.prompt.enter()*
`libmodal.prompt`.enter({name}, {instruction} [, {completions}])
@ -437,23 +450,19 @@ LAYERS *libmodal-examples-layers*
>
local libmodal = require('libmodal')
-- create the keymap
-- `gg` and `G` will be switched.
local layerKeymap = {
['n'] = {
['gg'] = {
['rhs'] = 'G',
['noremap'] = true
-- save the exit function
local exitFunc = libmodal.layer.enter({
['n'] = { -- normal mode
['gg'] = { -- remap `gg`
['rhs'] = 'G', -- map it to `G`
['noremap'] = true -- don't remap
},
['G'] = {
['rhs'] = 'gg',
['noremap'] = true
['G'] = { -- remap `G`
['rhs'] = 'gg', -- map it to `gg`
['noremap'] = true -- don't remap
}
}
}
-- save the exit function
local exitFunc = libmodal.layer.exit()
})
-- exit the mode in five seconds
vim.loop.new_timer():start(5000, 0,

@ -1,7 +1,7 @@
local libmodal = require('libmodal')
-- create a new layer.
local exitFunc = libmodal.layer.enter('FOO', {
local exitFunc = libmodal.layer.enter({
['n'] = { -- normal mode mappings
['gg'] = { -- remap `gg`
['rhs'] = 'G', -- map it to `G`

@ -1,7 +1,7 @@
local libmodal = require('libmodal')
-- create a new layer.
local layer = libmodal.Layer.new('FOO', {
local layer = libmodal.Layer.new({
['n'] = { -- normal mode mappings
['gg'] = { -- remap `gg`
['rhs'] = 'G', -- map it to `G`

@ -12,8 +12,8 @@ local libmodal = require('libmodal/src')
*/
--]]
libmodal.layer = {['enter'] = function(name, mappings)
local layer = libmodal.Layer.new(name, mappings)
libmodal.layer = {['enter'] = function(keymap)
local layer = libmodal.Layer.new(keymap)
layer:enter()
return function() layer:exit() end
end}

@ -48,7 +48,7 @@ local _metaLayer = require('libmodal/src/classes').new(Layer.TYPE)
---------------------------
function _metaLayer:enter()
if self._priorKeymap then
error('This layer has already been entered.')
error('This layer has already been entered. `:exit()` before entering again.')
end
-- add local aliases.
@ -227,19 +227,18 @@ end
-----------------------------------------------------
--[[ SUMMARY:
* Create a new `Layer` for `commands`, `mappings`, and `options`.
* Create a new `Layer` for the buffer-local keymap.
]]
--[[ PARAMS:
* `name` => the name of the layer.
* `mappings` => the list of user mappings to replace.
]]
--[[ RETURNS:
* A new `Layer`.
]]
-----------------------------------------------------
function Layer.new(name, mappings)
function Layer.new(keymap)
return setmetatable(
{['_keymap'] = mappings, ['name'] = name},
{['_keymap'] = keymap},
_metaLayer
)
end

Loading…
Cancel
Save