You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nvim-libmodal/examples/submodes.vim

22 lines
595 B
VimL

" This is a counter.
let s:fooModeRecurse = 1
" This is a function to increase the counter every time that 'z' is pressed.
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
" This function wraps around calling libmodal so that the other function can recursively call it.
function! s:enter() abort
call luaeval("require('libmodal').mode.enter('FOO'.._A, 's:fooMode')", s:fooModeRecurse)
endfunction
" Begin the recursion.
call s:enter()