refactor(tests): lint decorations_spec, float_spec, multigrid_spec #33274

Problem:
decorations_spec.lua, float_spec.lua, multigrid_spec.lua are not
auto-formatted.

Solution:
Add a special `formatlua2` cmake target, which invokes `stylua` with
an alternative `.stylua2.toml` config.
This commit is contained in:
Justin M. Keyes
2025-05-06 18:00:20 -07:00
committed by GitHub
parent a81d2b6703
commit f5b5f2095e
8 changed files with 5968 additions and 3749 deletions

8
.stylua2.toml Normal file
View File

@ -0,0 +1,8 @@
# Alternative settings for special snowflakes like: decorations_spec.lua, multigrid_spec.lua, etc.
column_width = 140
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
call_parentheses = "Input"

View File

@ -1,15 +1,15 @@
/build/ build/
/.deps/ .deps/
/runtime/lua/coxpcall.lua runtime/lua/coxpcall.lua
/runtime/lua/uv/_meta.lua runtime/lua/uv/_meta.lua
/runtime/lua/vim/_meta runtime/lua/vim/_meta
/runtime/lua/vim/re.lua runtime/lua/vim/re.lua
# These are formatted explicitly by the "formatlua2" build task.
test/functional/ui/decorations_spec.lua test/functional/ui/decorations_spec.lua
test/functional/ui/float_spec.lua test/functional/ui/float_spec.lua
test/functional/ui/multigrid_spec.lua test/functional/ui/multigrid_spec.lua
/test/functional/fixtures/lua/syntax_error.lua test/functional/fixtures/lua/syntax_error.lua
/test/functional/legacy/030_fileformats_spec.lua test/functional/legacy/030_fileformats_spec.lua
/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
/test/functional/lua/luaeval_spec.lua

View File

@ -281,7 +281,15 @@ add_glob_target(
GLOB_DIRS ${STYLUA_DIRS} GLOB_DIRS ${STYLUA_DIRS}
GLOB_PAT *.lua GLOB_PAT *.lua
TOUCH_STRATEGY PER_DIR) TOUCH_STRATEGY PER_DIR)
# Special handling of some files (which are ignored in .styluaignore).
# Workaround because stylua doesn't(?) support file-specific settings.
add_custom_target(formatlua2
COMMAND ${STYLUA_PRG} --config-path "${PROJECT_SOURCE_DIR}/.stylua2.toml"
"${PROJECT_SOURCE_DIR}/test/functional/ui/decorations_spec.lua"
"${PROJECT_SOURCE_DIR}/test/functional/ui/float_spec.lua"
"${PROJECT_SOURCE_DIR}/test/functional/ui/multigrid_spec.lua"
)
add_dependencies(formatlua formatlua2)
add_custom_target(format) add_custom_target(format)
add_dependencies(format formatc formatlua) add_dependencies(format formatc formatlua)

View File

@ -170,6 +170,7 @@ local ty_name = Cg(ty_ident, 'name')
local opt_parent = opt(colon * Cg(ty_ident, 'parent')) local opt_parent = opt(colon * Cg(ty_ident, 'parent'))
local lname = (ident + ellipsis) * opt(P('?')) local lname = (ident + ellipsis) * opt(P('?'))
-- stylua: ignore
local grammar = P { local grammar = P {
rep1(P('@') * (v.ats + v.ext_ats)), rep1(P('@') * (v.ats + v.ext_ats)),

View File

@ -40,16 +40,22 @@ describe('luaeval()', function()
describe('second argument', function() describe('second argument', function()
it('is successfully received', function() it('is successfully received', function()
local q = {t=true, f=false, --[[n=NIL,]] d={l={'string', 42, 0.42}}} local q = {
eq(q, fn.luaeval("_A", q)) t = true,
f = false, --[[n=NIL,]]
d = { l = { 'string', 42, 0.42 } },
}
eq(q, fn.luaeval('_A', q))
-- Not tested: nil, funcrefs, returned object identity: behaviour will -- Not tested: nil, funcrefs, returned object identity: behaviour will
-- most likely change. -- most likely change.
end) end)
end) end)
describe('lua values', function() describe('lua values', function()
it('are successfully transformed', function() it('are successfully transformed', function()
eq({n=1, f=1.5, s='string', l={4, 2}}, eq(
fn.luaeval('{n=1, f=1.5, s="string", l={4, 2}}')) { n = 1, f = 1.5, s = 'string', l = { 4, 2 } },
fn.luaeval('{n=1, f=1.5, s="string", l={4, 2}}')
)
-- Not tested: nil inside containers: behaviour will most likely change. -- Not tested: nil inside containers: behaviour will most likely change.
eq(NIL, fn.luaeval('nil')) eq(NIL, fn.luaeval('nil'))
eq({ [''] = 1 }, fn.luaeval('{[""]=1}')) eq({ [''] = 1 }, fn.luaeval('{[""]=1}'))
@ -59,7 +65,7 @@ describe('luaeval()', function()
it('are successfully transformed', function() it('are successfully transformed', function()
command('lua rawset(_G, "d", {})') command('lua rawset(_G, "d", {})')
command('lua rawset(d, "d", d)') command('lua rawset(d, "d", d)')
eq('\n{\'d\': {...@0}}', fn.execute('echo luaeval("d")')) eq("\n{'d': {...@0}}", fn.execute('echo luaeval("d")'))
command('lua rawset(_G, "l", {})') command('lua rawset(_G, "l", {})')
command('lua table.insert(l, l)') command('lua table.insert(l, l)')
@ -94,7 +100,7 @@ describe('luaeval()', function()
eq(1.5, fn.luaeval('1.5')) eq(1.5, fn.luaeval('1.5'))
eq(5, eval('"1.5"->luaeval()->type()')) eq(5, eval('"1.5"->luaeval()->type()'))
eq("test", fn.luaeval('"test"')) eq('test', fn.luaeval('"test"'))
eq(1, eval('"\'test\'"->luaeval()->type()')) eq(1, eval('"\'test\'"->luaeval()->type()'))
eq('', fn.luaeval('""')) eq('', fn.luaeval('""'))
@ -126,12 +132,16 @@ describe('luaeval()', function()
local level = 30 local level = 30
eq(nested_by_level[level].o, fn.luaeval(nested_by_level[level].s)) eq(nested_by_level[level].o, fn.luaeval(nested_by_level[level].s))
eq({_TYPE={}, _VAL={{'\000\n\000', '\000\n\000\000'}}}, eq(
fn.luaeval([[{['\0\n\0']='\0\n\0\0'}]])) { _TYPE = {}, _VAL = { { '\000\n\000', '\000\n\000\000' } } },
fn.luaeval([[{['\0\n\0']='\0\n\0\0'}]])
)
eq(1, eval([[luaeval('{["\0\n\0"]="\0\n\0\0"}')._TYPE is v:msgpack_types.map]])) eq(1, eval([[luaeval('{["\0\n\0"]="\0\n\0\0"}')._TYPE is v:msgpack_types.map]]))
eq(eval("v:t_blob"), eval([[type(luaeval('{["\0\n\0"]="\0\n\0\0"}')._VAL[0][0])]])) eq(eval('v:t_blob'), eval([[type(luaeval('{["\0\n\0"]="\0\n\0\0"}')._VAL[0][0])]]))
eq({nested={{_TYPE={}, _VAL={{'\000\n\000', '\000\n\000\000'}}}}}, eq(
fn.luaeval([[{nested={{['\0\n\0']='\0\n\0\0'}}}]])) { nested = { { _TYPE = {}, _VAL = { { '\000\n\000', '\000\n\000\000' } } } } },
fn.luaeval([[{nested={{['\0\n\0']='\0\n\0\0'}}}]])
)
end) end)
it('correctly passes scalars as argument', function() it('correctly passes scalars as argument', function()
@ -158,8 +168,7 @@ describe('luaeval()', function()
local function mapsp(...) local function mapsp(...)
local val = '' local val = ''
for i = 1, (select('#', ...) / 2) do for i = 1, (select('#', ...) / 2) do
val = ('%s[%s,%s],'):format(val, select(i * 2 - 1, ...), val = ('%s[%s,%s],'):format(val, select(i * 2 - 1, ...), select(i * 2, ...))
select(i * 2, ...))
end end
return sp('map', '[' .. val .. ']') return sp('map', '[' .. val .. ']')
end end
@ -182,22 +191,23 @@ describe('luaeval()', function()
eq({ 0, true }, luaevalarg(sp('boolean', 1))) eq({ 0, true }, luaevalarg(sp('boolean', 1)))
eq({ 0, false }, luaevalarg(sp('boolean', 0))) eq({ 0, false }, luaevalarg(sp('boolean', 0)))
eq({ 0, NIL }, luaevalarg(sp('nil', 0))) eq({ 0, NIL }, luaevalarg(sp('nil', 0)))
eq({0, {[""]=""}}, luaevalarg(mapsp(sp('string', '[""]'), '""'))) eq({ 0, { [''] = '' } }, luaevalarg(mapsp(sp('string', '[""]'), '""')))
end) end)
it('issues an error in some cases', function() it('issues an error in some cases', function()
eq("Vim(call):E5100: Cannot convert given Lua table: table should contain either only integer keys or only string keys", eq(
exc_exec('call luaeval("{1, foo=2}")')) 'Vim(call):E5100: Cannot convert given Lua table: table should contain either only integer keys or only string keys',
exc_exec('call luaeval("{1, foo=2}")')
startswith("Vim(call):E5107: Lua: [string \"luaeval()\"]:", )
exc_exec('call luaeval("1, 2, 3")'))
startswith("Vim(call):E5108: Lua: [string \"luaeval()\"]:",
exc_exec('call luaeval("(nil)()")'))
startswith('Vim(call):E5107: Lua: [string "luaeval()"]:', exc_exec('call luaeval("1, 2, 3")'))
startswith('Vim(call):E5108: Lua: [string "luaeval()"]:', exc_exec('call luaeval("(nil)()")'))
end) end)
it('should handle sending lua functions to viml', function() it('should handle sending lua functions to viml', function()
eq(true, exec_lua [[ eq(
true,
exec_lua [[
can_pass_lua_callback_to_vim_from_lua_result = nil can_pass_lua_callback_to_vim_from_lua_result = nil
vim.fn.call(function() vim.fn.call(function()
@ -205,11 +215,14 @@ describe('luaeval()', function()
end, {}) end, {})
return can_pass_lua_callback_to_vim_from_lua_result return can_pass_lua_callback_to_vim_from_lua_result
]]) ]]
)
end) end)
it('run functions even in timers', function() it('run functions even in timers', function()
eq(true, exec_lua [[ eq(
true,
exec_lua [[
can_pass_lua_callback_to_vim_from_lua_result = nil can_pass_lua_callback_to_vim_from_lua_result = nil
vim.fn.timer_start(50, function() vim.fn.timer_start(50, function()
@ -221,11 +234,14 @@ describe('luaeval()', function()
end) end)
return can_pass_lua_callback_to_vim_from_lua_result return can_pass_lua_callback_to_vim_from_lua_result
]]) ]]
)
end) end)
it('can run named functions more than once', function() it('can run named functions more than once', function()
eq(5, exec_lua [[ eq(
5,
exec_lua [[
count_of_vals = 0 count_of_vals = 0
vim.fn.timer_start(5, function() vim.fn.timer_start(5, function()
@ -237,11 +253,14 @@ describe('luaeval()', function()
end) end)
return count_of_vals return count_of_vals
]]) ]]
)
end) end)
it('can handle clashing names', function() it('can handle clashing names', function()
eq(1, exec_lua [[ eq(
1,
exec_lua [[
local f_loc = function() return 1 end local f_loc = function() return 1 end
local result = nil local result = nil
@ -253,11 +272,14 @@ describe('luaeval()', function()
vim.wait(1000, function() return result ~= nil end) vim.wait(1000, function() return result ~= nil end)
return result return result
]]) ]]
)
end) end)
it('can handle functions with errors', function() it('can handle functions with errors', function()
eq(true, exec_lua [[ eq(
true,
exec_lua [[
vim.fn.timer_start(10, function() vim.fn.timer_start(10, function()
error("dead function") error("dead function")
end) end)
@ -265,7 +287,8 @@ describe('luaeval()', function()
vim.wait(1000, function() return false end) vim.wait(1000, function() return false end)
return true return true
]]) ]]
)
end) end)
it('should handle passing functions around', function() it('should handle passing functions around', function()
@ -276,7 +299,9 @@ describe('luaeval()', function()
endfunction endfunction
]] ]]
eq("Hello Vim I'm Lua", exec_lua [[ eq(
"Hello Vim I'm Lua",
exec_lua [[
can_pass_lua_callback_to_vim_from_lua_result = "" can_pass_lua_callback_to_vim_from_lua_result = ""
vim.fn.VimCanCallLuaCallbacks( vim.fn.VimCanCallLuaCallbacks(
@ -285,7 +310,8 @@ describe('luaeval()', function()
) )
return can_pass_lua_callback_to_vim_from_lua_result return can_pass_lua_callback_to_vim_from_lua_result
]]) ]]
)
end) end)
it('should handle funcrefs', function() it('should handle funcrefs', function()
@ -296,7 +322,9 @@ describe('luaeval()', function()
endfunction endfunction
]] ]]
eq("Hello Vim I'm Lua", exec_lua [[ eq(
"Hello Vim I'm Lua",
exec_lua [[
can_pass_lua_callback_to_vim_from_lua_result = "" can_pass_lua_callback_to_vim_from_lua_result = ""
vim.funcref('VimCanCallLuaCallbacks')( vim.funcref('VimCanCallLuaCallbacks')(
@ -305,11 +333,14 @@ describe('luaeval()', function()
) )
return can_pass_lua_callback_to_vim_from_lua_result return can_pass_lua_callback_to_vim_from_lua_result
]]) ]]
)
end) end)
it('should work with metatables using __call', function() it('should work with metatables using __call', function()
eq(1, exec_lua [[ eq(
1,
exec_lua [[
local this_is_local_variable = false local this_is_local_variable = false
local callable_table = setmetatable({x = 1}, { local callable_table = setmetatable({x = 1}, {
__call = function(t, ...) __call = function(t, ...)
@ -324,11 +355,14 @@ describe('luaeval()', function()
end) end)
return this_is_local_variable return this_is_local_variable
]]) ]]
)
end) end)
it('should handle being called from a timer once.', function() it('should handle being called from a timer once.', function()
eq(3, exec_lua [[ eq(
3,
exec_lua [[
local this_is_local_variable = false local this_is_local_variable = false
local callable_table = setmetatable({5, 4, 3, 2, 1}, { local callable_table = setmetatable({5, 4, 3, 2, 1}, {
__call = function(t, ...) this_is_local_variable = t[3] end __call = function(t, ...) this_is_local_variable = t[3] end
@ -340,11 +374,14 @@ describe('luaeval()', function()
end) end)
return this_is_local_variable return this_is_local_variable
]]) ]]
)
end) end)
it('should call functions once with __call metamethod', function() it('should call functions once with __call metamethod', function()
eq(true, exec_lua [[ eq(
true,
exec_lua [[
local this_is_local_variable = false local this_is_local_variable = false
local callable_table = setmetatable({a = true, b = false}, { local callable_table = setmetatable({a = true, b = false}, {
__call = function(t, ...) this_is_local_variable = t.a end __call = function(t, ...) this_is_local_variable = t.a end
@ -354,11 +391,14 @@ describe('luaeval()', function()
vim.fn.call(callable_table, {}) vim.fn.call(callable_table, {})
return this_is_local_variable return this_is_local_variable
]]) ]]
)
end) end)
it('should work with lists using __call', function() it('should work with lists using __call', function()
eq(3, exec_lua [[ eq(
3,
exec_lua [[
local this_is_local_variable = false local this_is_local_variable = false
local mt = { local mt = {
__call = function(t, ...) __call = function(t, ...)
@ -382,16 +422,20 @@ describe('luaeval()', function()
end) end)
return this_is_local_variable return this_is_local_variable
]]) ]]
)
end) end)
it('should not work with tables not using __call', function() it('should not work with tables not using __call', function()
eq({false, 'Vim:E921: Invalid callback argument'}, exec_lua [[ eq(
{ false, 'Vim:E921: Invalid callback argument' },
exec_lua [[
local this_is_local_variable = false local this_is_local_variable = false
local callable_table = setmetatable({x = 1}, {}) local callable_table = setmetatable({x = 1}, {})
return {pcall(function() vim.fn.timer_start(5, callable_table) end)} return {pcall(function() vim.fn.timer_start(5, callable_table) end)}
]]) ]]
)
end) end)
it('correctly converts containers with type_idx', function() it('correctly converts containers with type_idx', function()
@ -402,8 +446,14 @@ describe('luaeval()', function()
eq({}, fn.luaeval('{[vim.type_idx]=vim.types.array}')) eq({}, fn.luaeval('{[vim.type_idx]=vim.types.array}'))
-- Presence of type_idx makes Vim ignore some keys -- Presence of type_idx makes Vim ignore some keys
eq({42}, fn.luaeval('{[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}')) eq(
eq({foo=2}, fn.luaeval('{[vim.type_idx]=vim.types.dictionary, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}')) { 42 },
fn.luaeval('{[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}')
)
eq(
{ foo = 2 },
fn.luaeval('{[vim.type_idx]=vim.types.dictionary, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}')
)
eq(10, fn.luaeval('{[vim.type_idx]=vim.types.float, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}')) eq(10, fn.luaeval('{[vim.type_idx]=vim.types.float, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}'))
-- The following should not crash -- The following should not crash
@ -428,19 +478,23 @@ describe('luaeval()', function()
it('errors out correctly when doing incorrect things in lua', function() it('errors out correctly when doing incorrect things in lua', function()
-- Conversion errors -- Conversion errors
eq('Vim(call):E5108: Lua: [string "luaeval()"]:1: attempt to call field \'xxx_nonexistent_key_xxx\' (a nil value)', eq(
remove_trace(exc_exec([[call luaeval("vim.xxx_nonexistent_key_xxx()")]]))) 'Vim(call):E5108: Lua: [string "luaeval()"]:1: attempt to call field \'xxx_nonexistent_key_xxx\' (a nil value)',
eq('Vim(call):E5108: Lua: [string "luaeval()"]:1: ERROR', remove_trace(exc_exec([[call luaeval("vim.xxx_nonexistent_key_xxx()")]]))
remove_trace(exc_exec([[call luaeval("error('ERROR')")]]))) )
eq('Vim(call):E5108: Lua: [NULL]', eq(
remove_trace(exc_exec([[call luaeval("error(nil)")]]))) 'Vim(call):E5108: Lua: [string "luaeval()"]:1: ERROR',
remove_trace(exc_exec([[call luaeval("error('ERROR')")]]))
)
eq('Vim(call):E5108: Lua: [NULL]', remove_trace(exc_exec([[call luaeval("error(nil)")]])))
end) end)
it('does not leak memory when called with too long line', it('does not leak memory when called with too long line', function()
function()
local s = ('x'):rep(65536) local s = ('x'):rep(65536)
eq('Vim(call):E5107: Lua: [string "luaeval()"]:1: unexpected symbol near \')\'', eq(
exc_exec([[call luaeval("(']] .. s ..[[' + )")]])) 'Vim(call):E5107: Lua: [string "luaeval()"]:1: unexpected symbol near \')\'',
exc_exec([[call luaeval("(']] .. s .. [[' + )")]])
)
eq(s, fn.luaeval('"' .. s .. '"')) eq(s, fn.luaeval('"' .. s .. '"'))
end) end)
end) end)
@ -478,12 +532,14 @@ describe('v:lua', function()
eq(7, eval('v:lua.foo(3,4,v:null)')) eq(7, eval('v:lua.foo(3,4,v:null)'))
eq(true, exec_lua([[return _G.val == vim.NIL]])) eq(true, exec_lua([[return _G.val == vim.NIL]]))
eq(NIL, eval('v:lua.mymod.noisy("eval")')) eq(NIL, eval('v:lua.mymod.noisy("eval")'))
eq("hey eval", api.nvim_get_current_line()) eq('hey eval', api.nvim_get_current_line())
eq("string: abc", eval('v:lua.mymod.whatis(0z616263)')) eq('string: abc', eval('v:lua.mymod.whatis(0z616263)'))
eq("string: ", eval('v:lua.mymod.whatis(v:_null_blob)')) eq('string: ', eval('v:lua.mymod.whatis(v:_null_blob)'))
eq("Vim:E5108: Lua: [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)", eq(
pcall_err(eval, 'v:lua.mymod.crashy()')) 'Vim:E5108: Lua: [string "<nvim>"]:0: attempt to call global \'nonexistent\' (a nil value)',
pcall_err(eval, 'v:lua.mymod.crashy()')
)
end) end)
it('works when called as a method', function() it('works when called as a method', function()
@ -491,38 +547,44 @@ describe('v:lua', function()
eq(true, exec_lua([[return _G.val == nil]])) eq(true, exec_lua([[return _G.val == nil]]))
eq(321, eval('300->v:lua.foo(21, "boop")')) eq(321, eval('300->v:lua.foo(21, "boop")'))
eq("boop", exec_lua([[return _G.val]])) eq('boop', exec_lua([[return _G.val]]))
eq(NIL, eval('"there"->v:lua.mymod.noisy()')) eq(NIL, eval('"there"->v:lua.mymod.noisy()'))
eq("hey there", api.nvim_get_current_line()) eq('hey there', api.nvim_get_current_line())
eq({ 5, 10, 15, 20 }, eval('[[1], [2, 3], [4]]->v:lua.vim.tbl_flatten()->map({_, v -> v * 5})')) eq({ 5, 10, 15, 20 }, eval('[[1], [2, 3], [4]]->v:lua.vim.tbl_flatten()->map({_, v -> v * 5})'))
eq("Vim:E5108: Lua: [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)", eq(
pcall_err(eval, '"huh?"->v:lua.mymod.crashy()')) 'Vim:E5108: Lua: [string "<nvim>"]:0: attempt to call global \'nonexistent\' (a nil value)',
pcall_err(eval, '"huh?"->v:lua.mymod.crashy()')
)
end) end)
it('works in :call', function() it('works in :call', function()
command(":call v:lua.mymod.noisy('command')") command(":call v:lua.mymod.noisy('command')")
eq("hey command", api.nvim_get_current_line()) eq('hey command', api.nvim_get_current_line())
eq("Vim(call):E5108: Lua: [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)", eq(
pcall_err(command, 'call v:lua.mymod.crashy()')) 'Vim(call):E5108: Lua: [string "<nvim>"]:0: attempt to call global \'nonexistent\' (a nil value)',
pcall_err(command, 'call v:lua.mymod.crashy()')
)
end) end)
it('works in func options', function() it('works in func options', function()
local screen = Screen.new(60, 8) local screen = Screen.new(60, 8)
api.nvim_set_option_value('omnifunc', 'v:lua.mymod.omni', {}) api.nvim_set_option_value('omnifunc', 'v:lua.mymod.omni', {})
feed('isome st<c-x><c-o>') feed('isome st<c-x><c-o>')
screen:expect{grid=[[ screen:expect {
grid = [[
some stuff^ | some stuff^ |
{1:~ }{12: stuff }{1: }| {1:~ }{12: stuff }{1: }|
{1:~ }{4: steam }{1: }| {1:~ }{4: steam }{1: }|
{1:~ }{4: strange things }{1: }| {1:~ }{4: strange things }{1: }|
{1:~ }|*3 {1:~ }|*3
{5:-- Omni completion (^O^N^P) }{6:match 1 of 3} | {5:-- Omni completion (^O^N^P) }{6:match 1 of 3} |
]]} ]],
}
api.nvim_set_option_value('operatorfunc', 'v:lua.mymod.noisy', {}) api.nvim_set_option_value('operatorfunc', 'v:lua.mymod.noisy', {})
feed('<Esc>g@g@') feed('<Esc>g@g@')
eq("hey line", api.nvim_get_current_line()) eq('hey line', api.nvim_get_current_line())
end) end)
it('supports packages', function() it('supports packages', function()
@ -535,25 +597,43 @@ describe('v:lua', function()
end) end)
it('throw errors for invalid use', function() it('throw errors for invalid use', function()
eq([[Vim(let):E15: Invalid expression: "v:lua.func"]], pcall_err(command, "let g:Func = v:lua.func")) eq(
eq([[Vim(let):E15: Invalid expression: "v:lua"]], pcall_err(command, "let g:Func = v:lua")) [[Vim(let):E15: Invalid expression: "v:lua.func"]],
eq([[Vim(let):E15: Invalid expression: "v:['lua']"]], pcall_err(command, "let g:Func = v:['lua']")) pcall_err(command, 'let g:Func = v:lua.func')
)
eq([[Vim(let):E15: Invalid expression: "v:lua"]], pcall_err(command, 'let g:Func = v:lua'))
eq(
[[Vim(let):E15: Invalid expression: "v:['lua']"]],
pcall_err(command, "let g:Func = v:['lua']")
)
eq([[Vim:E15: Invalid expression: "v:['lua'].foo()"]], pcall_err(eval, "v:['lua'].foo()")) eq([[Vim:E15: Invalid expression: "v:['lua'].foo()"]], pcall_err(eval, "v:['lua'].foo()"))
eq("Vim(call):E461: Illegal variable name: v:['lua']", pcall_err(command, "call v:['lua'].baar()")) eq(
eq("Vim:E1085: Not a callable type: v:lua", pcall_err(eval, "v:lua()")) "Vim(call):E461: Illegal variable name: v:['lua']",
pcall_err(command, "call v:['lua'].baar()")
)
eq('Vim:E1085: Not a callable type: v:lua', pcall_err(eval, 'v:lua()'))
eq("Vim(let):E46: Cannot change read-only variable \"v:['lua']\"", pcall_err(command, "let v:['lua'] = 'xx'")) eq(
eq("Vim(let):E46: Cannot change read-only variable \"v:lua\"", pcall_err(command, "let v:lua = 'xx'")) 'Vim(let):E46: Cannot change read-only variable "v:[\'lua\']"',
pcall_err(command, "let v:['lua'] = 'xx'")
)
eq(
'Vim(let):E46: Cannot change read-only variable "v:lua"',
pcall_err(command, "let v:lua = 'xx'")
)
eq("Vim:E107: Missing parentheses: v:lua.func", pcall_err(eval, "'bad'->v:lua.func")) eq('Vim:E107: Missing parentheses: v:lua.func', pcall_err(eval, "'bad'->v:lua.func"))
eq("Vim:E274: No white space allowed before parenthesis", pcall_err(eval, "'bad'->v:lua.func ()")) eq(
eq("Vim:E107: Missing parentheses: v:lua", pcall_err(eval, "'bad'->v:lua")) 'Vim:E274: No white space allowed before parenthesis',
eq("Vim:E1085: Not a callable type: v:lua", pcall_err(eval, "'bad'->v:lua()")) pcall_err(eval, "'bad'->v:lua.func ()")
)
eq('Vim:E107: Missing parentheses: v:lua', pcall_err(eval, "'bad'->v:lua"))
eq('Vim:E1085: Not a callable type: v:lua', pcall_err(eval, "'bad'->v:lua()"))
eq([[Vim:E15: Invalid expression: "v:lua.()"]], pcall_err(eval, "'bad'->v:lua.()")) eq([[Vim:E15: Invalid expression: "v:lua.()"]], pcall_err(eval, "'bad'->v:lua.()"))
eq("Vim:E1085: Not a callable type: v:lua", pcall_err(eval, "v:lua()")) eq('Vim:E1085: Not a callable type: v:lua', pcall_err(eval, 'v:lua()'))
eq([[Vim:E15: Invalid expression: "v:lua.()"]], pcall_err(eval, "v:lua.()")) eq([[Vim:E15: Invalid expression: "v:lua.()"]], pcall_err(eval, 'v:lua.()'))
end) end)
describe('invalid use in fold text', function() describe('invalid use in fold text', function()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff