Add more examples

pull/6/head
Iron-E 4 years ago
parent 26164953b6
commit f6813a55c1
No known key found for this signature in database
GPG Key ID: 19B71B7B7B021D22

@ -716,6 +716,8 @@ When submitting an issue, please describe the following:
Additions: ~
* Ability to pass `function`s into |libmodal-mode| from Vimscript.
* Ability to pass `function`s into |libmodal-prompt| from Vimscript.
* Add examples for doing almost everything that this plugin can do, from
Vimscript (although I still think Lua makes it easier).
0.6.2 ~

@ -0,0 +1,19 @@
" Create a new layer.
let s:layer = {
\ 'n': {
\ 'gg': {
\ 'rhs': 'G',
\ 'noremap': v:true,
\ },
\ 'G': {
\ 'rhs': 'gg',
\ 'noremap': v:true
\ }
\ }
\}
" Capture the exit function
let s:exitFunc = luaeval("require('libmodal').layer.enter(_A)", s:layer)
" Call the exit function in 5 seconds.
call timer_start(5000, s:exitFunc)

@ -0,0 +1,14 @@
let s:commandList = ['new', 'close', 'last']
function! s:fooMode() abort
let l:userInput = g:fooModeInput
if userInput == 'new'
tabnew
elseif userInput == 'close'
tabclose
elseif userInput == 'last'
tablast
endif
endfunction
call luaeval("require('libmodal').prompt.enter('FOO', 's:fooMode', _A)", s:commandList)

@ -0,0 +1,17 @@
let s:fooModeRecurse = 1
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
function! s:enter() abort
call luaeval("require('libmodal').mode.enter('FOO'.._A, 's:fooMode')", s:fooModeRecurse)
endfunction
call s:enter()

@ -0,0 +1,17 @@
local api = vim.api
local libmodal = require('libmodal')
local function fooMode()
local userInput = string.char(
api.nvim_get_var('fooModeInput')
)
if userInput == '' then
api.nvim_command("echom 'You cant leave using <Esc>.'")
elseif userInput == 'q' then
api.nvim_set_var('fooModeExit', true)
end
end
api.nvim_set_var('fooModeExit', 0)
libmodal.mode.enter('FOO', fooMode, true)
Loading…
Cancel
Save