diff options
author | shadmansaleh <shadmansaleh3@gmail.com> | 2021-06-03 07:07:51 +0600 |
---|---|---|
committer | shadmansaleh <shadmansaleh3@gmail.com> | 2021-06-11 01:01:03 +0600 |
commit | e1edc079dd0d0cb4a53e5998086568cf9d10a26a (patch) | |
tree | eb60874111545e69847809a765c8dc6921e37aa2 /test/functional/ex_cmds/source_spec.lua | |
parent | 92b6b3764cf75d01bcbf04fcf598140fc01e7902 (diff) | |
download | rneovim-e1edc079dd0d0cb4a53e5998086568cf9d10a26a.tar.gz rneovim-e1edc079dd0d0cb4a53e5998086568cf9d10a26a.tar.bz2 rneovim-e1edc079dd0d0cb4a53e5998086568cf9d10a26a.zip |
refactor(source): Move lua file detection to do_source
So now :source can run lua files too :)
* feat: Add support for :[ranged]source for lua files
Diffstat (limited to 'test/functional/ex_cmds/source_spec.lua')
-rw-r--r-- | test/functional/ex_cmds/source_spec.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua index 16d0dfb6a1..a03e1ae9ce 100644 --- a/test/functional/ex_cmds/source_spec.lua +++ b/test/functional/ex_cmds/source_spec.lua @@ -6,6 +6,9 @@ local clear = helpers.clear local meths = helpers.meths local feed = helpers.feed local feed_command = helpers.feed_command +local write_file = helpers.write_file +local exec = helpers.exec +local eval = helpers.eval describe(':source', function() before_each(function() @@ -44,4 +47,47 @@ describe(':source', function() command('source') eq('4', meths.exec('echo luaeval("y")', true)) end) + + it('can source lua files', function() + local test_file = 'test.lua' + write_file (test_file, [[vim.g.sourced_lua = 1]]) + + exec('source ' .. test_file) + + eq(1, eval('g:sourced_lua')) + os.remove(test_file) + end) + + it('can source selected region in lua file', function() + local test_file = 'test.lua' + + write_file (test_file, [[ + vim.g.b = 5 + vim.g.b = 6 + vim.g.b = 7 + ]]) + + command('edit '..test_file) + feed('ggjV') + feed_command(':source') + + eq(6, eval('g:b')) + os.remove(test_file) + end) + + it('can source current lua buffer without argument', function() + local test_file = 'test.lua' + + write_file (test_file, [[ + vim.g.c = 10 + vim.g.c = 11 + vim.g.c = 12 + ]]) + + command('edit '..test_file) + feed_command(':source') + + eq(12, eval('g:c')) + os.remove(test_file) + end) end) |