aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/commands_spec.lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2024-01-27 02:00:50 +0100
committerGitHub <noreply@github.com>2024-01-26 17:00:50 -0800
commitc2433589dca022a7f40cdcbd0cd1ad8aba6ee4a9 (patch)
tree4ec42e5d42d7c0bb5e674af2e94e1fe3eac2c837 /test/functional/lua/commands_spec.lua
parent0892c080d16776366a2fe289f9083cdc532ec56c (diff)
downloadrneovim-c2433589dca022a7f40cdcbd0cd1ad8aba6ee4a9.tar.gz
rneovim-c2433589dca022a7f40cdcbd0cd1ad8aba6ee4a9.tar.bz2
rneovim-c2433589dca022a7f40cdcbd0cd1ad8aba6ee4a9.zip
feat(ex_cmds): ranged :lua #27167
:{range}lua executes the specified lines in the current buffer as Lua code, regardless of its extension or 'filetype'. Close #27103
Diffstat (limited to 'test/functional/lua/commands_spec.lua')
-rw-r--r--test/functional/lua/commands_spec.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua
index 28a99a86f8..083f6f3541 100644
--- a/test/functional/lua/commands_spec.lua
+++ b/test/functional/lua/commands_spec.lua
@@ -55,6 +55,12 @@ describe(':lua command', function()
)
end)
it('throws catchable errors', function()
+ for _, cmd in ipairs({ 'lua', '1lua chunk' }) do
+ eq(
+ 'Vim(lua):E475: Invalid argument: exactly one of {chunk} and {range} required',
+ pcall_err(command, cmd)
+ )
+ end
eq(
[[Vim(lua):E5107: Error loading lua [string ":lua"]:0: unexpected symbol near ')']],
pcall_err(command, 'lua ()')
@@ -192,6 +198,25 @@ describe(':lua command', function()
exec_capture('=x(false)')
)
end)
+
+ it('works with range in current buffer', function()
+ local screen = Screen.new(40, 10)
+ screen:attach()
+ api.nvim_buf_set_lines(0, 0, 0, 0, { 'function x() print "hello" end', 'x()' })
+ feed(':1,2lua<CR>')
+ screen:expect {
+ grid = [[
+ function x() print "hello" end |
+ x() |
+ ^ |
+ {1:~ }|*6
+ hello |
+ ]],
+ attr_ids = {
+ [1] = { foreground = Screen.colors.Blue, bold = true },
+ },
+ }
+ end)
end)
describe(':luado command', function()