mirror of
https://github.com/Iron-E/nvim-libmodal
synced 2024-11-04 18:00:15 +00:00
29 lines
766 B
Lua
29 lines
766 B
Lua
local libmodal = require 'libmodal'
|
|
|
|
-- recurse counter
|
|
local foo_mode_recurse = 1
|
|
|
|
-- function which is called whenever the user presses a button
|
|
function FooMode()
|
|
-- append to the input history, the latest button press
|
|
local userInput = string.char(vim.g[
|
|
-- the input is a character number
|
|
'foo' .. tostring(foo_mode_recurse) .. 'ModeInput'
|
|
])
|
|
|
|
-- if the user pressed 'z', then increase the counter and recurse
|
|
if userInput == 'z' then
|
|
foo_mode_recurse = foo_mode_recurse + 1
|
|
Enter()
|
|
foo_mode_recurse = foo_mode_recurse - 1
|
|
end
|
|
end
|
|
|
|
-- function to wrap around entering the mode so it can be recursively called
|
|
function Enter()
|
|
libmodal.mode.enter('FOO' .. foo_mode_recurse, FooMode)
|
|
end
|
|
|
|
-- initially call the function to begin the demo
|
|
Enter()
|