diff options
author | Christian Clason <christian.clason@uni-due.de> | 2020-05-18 15:49:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 09:49:50 -0400 |
commit | f2894bffb024b712e69158d7914e9d9d3d495f72 (patch) | |
tree | 2c340fd7e346f4827247ed736ed9bc67abb32993 /test/functional/lua/vim_spec.lua | |
parent | a6be7a91809488adea23bf52bd77f0ed790bcbd3 (diff) | |
download | rneovim-f2894bffb024b712e69158d7914e9d9d3d495f72.tar.gz rneovim-f2894bffb024b712e69158d7914e9d9d3d495f72.tar.bz2 rneovim-f2894bffb024b712e69158d7914e9d9d3d495f72.zip |
lua: Add highlight.on_yank (#12279)
* add lua function to highlight yanked region
* extract namespace, better naming, default values
* add default for event argument
* free timer
* factor out mark to position calculation
* d'oh
* make sure timer stops before callback (cf. luv example)
* factor out timer, more documentation
* fixup
* validate function argument for schedule
* fix block selection past eol
* correct handling of multibyte characters
* move arguments around, some cleanup
* move utility functions to vim.lua
* use anonymous namespaces, avoid local api
* rename function
* add test for schedule_fn
* fix indent
* turn hl-yank into proper (hightlight) module
* factor out position-to-region function
mark extraction now part of highlight.on_yank
* rename schedule_fn to defer_fn
* add test for vim.region
* todo: handle double-width characters
* remove debug printout
* do not shadow arguments
* defer also callable table
* whitespace change
* move highlight to vim/highlight.lua
* add documentation
* add @return documentation
* test: add check before vim.defer fires
* doc: fixup
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 46ae56955b..2ea51e7b0b 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1046,4 +1046,24 @@ describe('lua stdlib', function() eq({}, exec_lua[[return {re1:match_line(0, 1, 1, 7)}]]) eq({0,3}, exec_lua[[return {re1:match_line(0, 1, 0, 7)}]]) end) -end) + + it('vim.defer_fn', function() + exec_lua [[ + vim.g.test = 0 + vim.defer_fn(function() vim.g.test = 1 end, 10) + ]] + eq(0, exec_lua[[return vim.g.test]]) + exec_lua [[vim.cmd("sleep 10m")]] + eq(1, exec_lua[[return vim.g.test]]) + end) + + it('vim.region', function() + helpers.insert(helpers.dedent( [[ + text tααt tααt text + text tαxt txtα tex + text tαxt tαxt + ]])) + eq({5,15}, exec_lua[[ return vim.region(0,{1,5},{1,14},'v',true)[1] ]]) + end) + + end) |