From 26164953b6a2f0148445f6f25617345816cf4467 Mon Sep 17 00:00:00 2001 From: Iron-E Date: Wed, 26 Aug 2020 18:26:11 -0400 Subject: [PATCH] Adjust documentation --- README.md | 4 ++-- doc/libmodal.txt | 27 +++++++++++++++++---------- examples/key-combos-manually.vim | 30 ++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 examples/key-combos-manually.vim diff --git a/README.md b/README.md index 5e44996..5b10922 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ See [vim-libmodal][libmodal] and the [docs](./doc) for more information. Alterna # Requirements -* Neovim 0.4+ - * Eventually 0.5 will be required. +* Neovim 0.4+. + * For compatability with `vim-libmodal`, Neovim 0.5+. * `vim-libmodal` is _not_ installed. [libmodal]: https://github.com/Iron-E/vim-libmodal diff --git a/doc/libmodal.txt b/doc/libmodal.txt index 116fbc6..bc8cb08 100644 --- a/doc/libmodal.txt +++ b/doc/libmodal.txt @@ -144,11 +144,9 @@ FUNCTIONS *libmodal-usage-functions* that |getchar()| completes. The user input is received through `g:{name}ModeInput` (see above). - *Error you cannot pass a function to Lua from Vimscript! -        - If you try to use a |funcref()| for {instruction}, it -        will fail, GUARANTEED. This is because of |E5004|. -        - If you want to use a |funcref()| for {instruction}, you -        must use a |Lua| `function` instead. + *Error you cannot pass a funcref to Lua from Vimscript! +        - If you want to use a |funcref()| for {instruction}, it +        must be the name of the function as a `string`. Note: Some QoL features are available by default when specifying a `dict`/`table` value for {instruction} that @@ -249,11 +247,9 @@ FUNCTIONS *libmodal-usage-functions* every time that |input()| completes. The user input is received through `g:{name}ModeInput` (see above). - *Error you cannot pass a function to Lua from Vimscript! -        - If you try to use a |funcref()| for {instruction}, it -        will fail, GUARANTEED. This is because of |E5004|. -        - If you want to use a |funcref()| for {instruction}, you -        must use a |Lua| `function` instead. + *Error you cannot pass a funcref to Lua from Vimscript! +        - If you want to use a |funcref()| for {instruction}, it +        must be the name of the function as a `string`. Note: If you want to create commands with arguments, you will need to use a `function`. @@ -715,6 +711,17 @@ When submitting an issue, please describe the following: ============================================================================== 8. Changelog *libmodal-changelog* +0.7.0 ~ + + Additions: ~ + * Ability to pass `function`s into |libmodal-mode| from Vimscript. + * Ability to pass `function`s into |libmodal-prompt| from Vimscript. + +0.6.2 ~ + + Fixes: ~ + * Remove unused variables + 0.6.1 ~ Fixes: ~ diff --git a/examples/key-combos-manually.vim b/examples/key-combos-manually.vim new file mode 100644 index 0000000..f654db7 --- /dev/null +++ b/examples/key-combos-manually.vim @@ -0,0 +1,30 @@ +let s:inputHistory = [] + +function! s:clear(indexToCheck) abort + if len(s:inputHistory) > a:indexToCheck + for i in range(len(s:inputHistory)) + let s:inputHistory[i] = v:null + endfor + endif +endfunction + +function! s:fooMode() abort + let s:inputHistory = add(s:inputHistory, nr2char(g:fooModeInput)) + + let l:index = 0 + if s:inputHistory[0] == 'z' + if get(s:inputHistory, 1, v:null) == 'f' + if get(s:inputHistory, 2, v:null) == 'o' + echom 'It works!' + else + let l:index = 2 + endif + else + let l:index = 1 + endif + endif + + call s:clear(l:index) +endfunction + +lua require('libmodal').mode.enter('FOO', 's:fooMode')