aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds/source_spec.lua
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-06-11 17:42:21 +0200
committerGitHub <noreply@github.com>2021-06-11 17:42:21 +0200
commit81a6b70880efa21dc45c6b222ca3c2d794c85b36 (patch)
treedbccb3560996a9ef3aac1ad176ada23dfe986cc2 /test/functional/ex_cmds/source_spec.lua
parentfa768152dc5523ce7656a55253a626eea5180396 (diff)
parente1edc079dd0d0cb4a53e5998086568cf9d10a26a (diff)
downloadrneovim-81a6b70880efa21dc45c6b222ca3c2d794c85b36.tar.gz
rneovim-81a6b70880efa21dc45c6b222ca3c2d794c85b36.tar.bz2
rneovim-81a6b70880efa21dc45c6b222ca3c2d794c85b36.zip
Merge pull request #14686 from shadmansaleh/feat/evaluate_plugin/lua
runtime: allow to use .lua files for most features defined as &rtp/{feature}/*.vim
Diffstat (limited to 'test/functional/ex_cmds/source_spec.lua')
-rw-r--r--test/functional/ex_cmds/source_spec.lua46
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)