mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user