nvim-libmodal/examples/submodes.vim

22 lines
595 B
VimL
Raw Normal View History

2020-08-27 16:10:01 +00:00
" This is a counter.
2020-08-26 22:48:48 +00:00
let s:fooModeRecurse = 1
2020-08-27 16:10:01 +00:00
" This is a function to increase the counter every time that 'z' is pressed.
2020-08-26 22:48:48 +00:00
function! s:fooMode() abort
let l:userInput = nr2char(g:foo{s:fooModeRecurse}ModeInput)
if l:userInput == 'z'
let s:fooModeRecurse += 1
call s:enter()
let s:fooModeRecurse -= 1
endif
endfunction
2020-08-27 16:10:01 +00:00
" This function wraps around calling libmodal so that the other function can recursively call it.
2020-08-26 22:48:48 +00:00
function! s:enter() abort
call luaeval("require('libmodal').mode.enter('FOO'.._A, 's:fooMode')", s:fooModeRecurse)
endfunction
2020-08-27 16:10:01 +00:00
" Begin the recursion.
2020-08-26 22:48:48 +00:00
call s:enter()