mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
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
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user