Merge pull request #22743 from bfredl/luaequals

feat(lua): allow `:=expr` as a shorter version of `:lua =expr`
This commit is contained in:
bfredl
2023-03-22 10:59:38 +01:00
committed by GitHub
10 changed files with 41 additions and 19 deletions

View File

@@ -146,6 +146,7 @@ describe(':lua command', function()
it('prints result of =expr', function()
exec_lua("x = 5")
eq("5", exec_capture(':lua =x'))
eq("5", exec_capture('=x'))
exec_lua("function x() return 'hello' end")
eq('hello', exec_capture(':lua = x()'))
exec_lua("x = {a = 1, b = 2}")
@@ -165,7 +166,7 @@ describe(':lua command', function()
false
nil
Error message]],
exec_capture(':lua =x(false)'))
exec_capture('=x(false)'))
end)
end)

View File

@@ -7,6 +7,19 @@ func Test_ex_equal()
let a = execute('=')
call assert_equal("\n2", a)
let a = execute('.=')
call assert_equal("\n1", a)
call assert_fails('3=', 'E16:')
bwipe!
endfunc
func Test_ex_equal_arg()
throw 'skipped: Nvim evaluates lua with := [arg]'
new
call setline(1, ["foo\tbar", "bar\tfoo"])
let a = execute('=#')
call assert_equal("\n2\n 1 foo bar", a)
@@ -22,10 +35,6 @@ func Test_ex_equal()
let a = execute('=p#')
call assert_equal("\n2\n 1 foo bar", a)
let a = execute('.=')
call assert_equal("\n1", a)
call assert_fails('3=', 'E16:')
call assert_fails('=x', 'E488:')
bwipe!