aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core/startup_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:18 +0100
committerJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:29 +0100
commit04f2f864e270e772c6326cefdf24947f0130e492 (patch)
tree46f83f909b888a66c741032ab955afc6eab84292 /test/functional/core/startup_spec.lua
parent59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff)
downloadrneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip
refactor: format test/*
Diffstat (limited to 'test/functional/core/startup_spec.lua')
-rw-r--r--test/functional/core/startup_spec.lua812
1 files changed, 543 insertions, 269 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index f6f7711c0a..ebf9deb86b 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -36,9 +36,23 @@ local endswith = helpers.endswith
describe('startup', function()
it('--clean', function()
clear()
- ok(string.find(alter_slashes(meths.get_option_value('runtimepath', {})), funcs.stdpath('config'), 1, true) ~= nil)
+ ok(
+ string.find(
+ alter_slashes(meths.get_option_value('runtimepath', {})),
+ funcs.stdpath('config'),
+ 1,
+ true
+ ) ~= nil
+ )
clear('--clean')
- ok(string.find(alter_slashes(meths.get_option_value('runtimepath', {})), funcs.stdpath('config'), 1, true) == nil)
+ ok(
+ string.find(
+ alter_slashes(meths.get_option_value('runtimepath', {})),
+ funcs.stdpath('config'),
+ 1,
+ true
+ ) == nil
+ )
end)
it('prevents remote UI infinite loop', function()
@@ -58,7 +72,7 @@ describe('startup', function()
finally(function()
os.remove(testfile)
end)
- clear({ args = {'--startuptime', testfile}})
+ clear({ args = { '--startuptime', testfile } })
assert_log('sourcing', testfile, 100)
assert_log("require%('vim%._editor'%)", testfile, 100)
end)
@@ -70,10 +84,13 @@ describe('startup', function()
screen:attach()
local id = funcs.termopen({
nvim_prog,
- '-u', 'NONE',
- '-i', 'NONE',
- '--cmd', 'set noruler',
- '-D'
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'set noruler',
+ '-D',
}, {
env = {
VIMRUNTIME = os.getenv('VIMRUNTIME'),
@@ -127,39 +144,48 @@ describe('startup', function()
vim.uv.os_setenv('ASAN_OPTIONS', asan_options .. ':detect_leaks=0')
]]
-- nvim -l foo.lua -arg1 -- a b c
- assert_l_out([[
+ assert_l_out(
+ [[
bufs:
nvim args: 7
lua args: { "-arg1", "--exitcode", "73", "--arg2",
[0] = "test/functional/fixtures/startup.lua"
}]],
{},
- { '-arg1', "--exitcode", "73", '--arg2' }
+ { '-arg1', '--exitcode', '73', '--arg2' }
)
eq(73, eval('v:shell_error'))
end)
it('Lua-error sets Nvim exitcode', function()
eq(0, eval('v:shell_error'))
- matches('E5113: .* my pearls!!',
- funcs.system({ nvim_prog, '-l', 'test/functional/fixtures/startup-fail.lua' }))
+ matches(
+ 'E5113: .* my pearls!!',
+ funcs.system({ nvim_prog, '-l', 'test/functional/fixtures/startup-fail.lua' })
+ )
eq(1, eval('v:shell_error'))
- matches('E5113: .* %[string "error%("whoa"%)"%]:1: whoa',
- funcs.system({ nvim_prog, '-l', '-' }, 'error("whoa")'))
+ matches(
+ 'E5113: .* %[string "error%("whoa"%)"%]:1: whoa',
+ funcs.system({ nvim_prog, '-l', '-' }, 'error("whoa")')
+ )
eq(1, eval('v:shell_error'))
end)
it('executes stdin "-"', function()
- assert_l_out('arg0=- args=2 whoa\n',
+ assert_l_out(
+ 'arg0=- args=2 whoa\n',
nil,
{ 'arg1', 'arg 2' },
'-',
- "print(('arg0=%s args=%d %s'):format(_G.arg[0], #_G.arg, 'whoa'))")
- assert_l_out('biiig input: 1000042\n',
+ "print(('arg0=%s args=%d %s'):format(_G.arg[0], #_G.arg, 'whoa'))"
+ )
+ assert_l_out(
+ 'biiig input: 1000042\n',
nil,
nil,
'-',
- ('print("biiig input: "..("%s"):len())'):format(string.rep('x', (1000 * 1000) + 42)))
+ ('print("biiig input: "..("%s"):len())'):format(string.rep('x', (1000 * 1000) + 42))
+ )
eq(0, eval('v:shell_error'))
end)
@@ -174,7 +200,8 @@ describe('startup', function()
it('sets _G.arg', function()
-- nvim -l foo.lua
- assert_l_out([[
+ assert_l_out(
+ [[
bufs:
nvim args: 3
lua args: {
@@ -187,7 +214,8 @@ describe('startup', function()
eq(0, eval('v:shell_error'))
-- nvim -l foo.lua [args]
- assert_l_out([[
+ assert_l_out(
+ [[
bufs:
nvim args: 7
lua args: { "-arg1", "--arg2", "--", "arg3",
@@ -200,20 +228,22 @@ describe('startup', function()
eq(0, eval('v:shell_error'))
-- nvim file1 file2 -l foo.lua -arg1 -- file3 file4
- assert_l_out([[
+ assert_l_out(
+ [[
bufs: file1 file2
nvim args: 10
lua args: { "-arg1", "arg 2", "--", "file3", "file4",
[0] = "test/functional/fixtures/startup.lua"
}
]],
- { 'file1', 'file2', },
+ { 'file1', 'file2' },
{ '-arg1', 'arg 2', '--', 'file3', 'file4' }
)
eq(0, eval('v:shell_error'))
-- nvim -l foo.lua <vim args>
- assert_l_out([[
+ assert_l_out(
+ [[
bufs:
nvim args: 5
lua args: { "-c", "set wrap?",
@@ -244,30 +274,50 @@ describe('startup', function()
end)
it('disables swapfile/shada/config/plugins', function()
- assert_l_out('updatecount=0 shadafile=NONE loadplugins=false scripts=1\n',
+ assert_l_out(
+ 'updatecount=0 shadafile=NONE loadplugins=false scripts=1\n',
nil,
nil,
'-',
[[print(('updatecount=%d shadafile=%s loadplugins=%s scripts=%d'):format(
- vim.o.updatecount, vim.o.shadafile, tostring(vim.o.loadplugins), math.max(1, #vim.fn.getscriptinfo())))]])
+ vim.o.updatecount, vim.o.shadafile, tostring(vim.o.loadplugins), math.max(1, #vim.fn.getscriptinfo())))]]
+ )
end)
end)
it('--cmd/-c/+ do not truncate long Lua print() message with --headless', function()
- local out = funcs.system({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless',
- '--cmd', 'lua print(("A"):rep(1234))',
- '-c', 'lua print(("B"):rep(1234))',
- '+lua print(("C"):rep(1234))',
- '+q' })
+ local out = funcs.system({
+ nvim_prog,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--headless',
+ '--cmd',
+ 'lua print(("A"):rep(1234))',
+ '-c',
+ 'lua print(("B"):rep(1234))',
+ '+lua print(("C"):rep(1234))',
+ '+q',
+ })
eq(('A'):rep(1234) .. '\r\n' .. ('B'):rep(1234) .. '\r\n' .. ('C'):rep(1234), out)
end)
it('pipe at both ends: has("ttyin")==0 has("ttyout")==0', function()
-- system() puts a pipe at both ends.
- local out = funcs.system({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless',
- '--cmd', nvim_set,
- '-c', [[echo has('ttyin') has('ttyout')]],
- '+q' })
+ local out = funcs.system({
+ nvim_prog,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--headless',
+ '--cmd',
+ nvim_set,
+ '-c',
+ [[echo has('ttyin') has('ttyout')]],
+ '+q',
+ })
eq('0 0', out)
end)
@@ -292,10 +342,14 @@ describe('startup', function()
-- Running in :terminal
funcs.termopen({
nvim_prog,
- '-u', 'NONE',
- '-i', 'NONE',
- '--cmd', nvim_set,
- '-c', 'echo has("ttyin") has("ttyout")',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ nvim_set,
+ '-c',
+ 'echo has("ttyin") has("ttyout")',
}, {
env = {
VIMRUNTIME = os.getenv('VIMRUNTIME'),
@@ -318,17 +372,24 @@ describe('startup', function()
os.remove('Xtest_startup_ttyout')
end)
-- Running in :terminal
- funcs.termopen(([["%s" -u NONE -i NONE --cmd "%s"]]
- ..[[ -c "call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')"]]
- ..[[ -c q | cat -v]]):format(nvim_prog, nvim_set), {
- env = {
- VIMRUNTIME = os.getenv('VIMRUNTIME'),
- },
- })
+ funcs.termopen(
+ (
+ [["%s" -u NONE -i NONE --cmd "%s"]]
+ .. [[ -c "call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')"]]
+ .. [[ -c q | cat -v]]
+ ):format(nvim_prog, nvim_set),
+ {
+ env = {
+ VIMRUNTIME = os.getenv('VIMRUNTIME'),
+ },
+ }
+ )
retry(nil, 3000, function()
sleep(1)
- eq('1\n0\n', -- stdin is a TTY, stdout is a pipe
- read_file('Xtest_startup_ttyout'))
+ eq(
+ '1\n0\n', -- stdin is a TTY, stdout is a pipe
+ read_file('Xtest_startup_ttyout')
+ )
end)
end)
@@ -341,18 +402,25 @@ describe('startup', function()
os.remove('Xtest_startup_ttyout')
end)
-- Running in :terminal
- funcs.termopen(([[echo foo | ]] -- Input from a pipe.
- ..[["%s" -u NONE -i NONE --cmd "%s"]]
- ..[[ -c "call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')"]]
- ..[[ -c q -- -]]):format(nvim_prog, nvim_set), {
- env = {
- VIMRUNTIME = os.getenv('VIMRUNTIME'),
- },
- })
+ funcs.termopen(
+ (
+ [[echo foo | ]] -- Input from a pipe.
+ .. [["%s" -u NONE -i NONE --cmd "%s"]]
+ .. [[ -c "call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')"]]
+ .. [[ -c q -- -]]
+ ):format(nvim_prog, nvim_set),
+ {
+ env = {
+ VIMRUNTIME = os.getenv('VIMRUNTIME'),
+ },
+ }
+ )
retry(nil, 3000, function()
sleep(1)
- eq('0\n1\n', -- stdin is a pipe, stdout is a TTY
- read_file('Xtest_startup_ttyout'))
+ eq(
+ '0\n1\n', -- stdin is a pipe, stdout is a TTY
+ read_file('Xtest_startup_ttyout')
+ )
end)
end)
@@ -363,13 +431,18 @@ describe('startup', function()
command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end
-- Running in :terminal
- funcs.termopen(([[echo foo | ]]
- .. [["%s" -u NONE -i NONE --cmd "%s"]]
- .. [[ -c "echo has('ttyin') has('ttyout')"]]):format(nvim_prog, nvim_set), {
- env = {
- VIMRUNTIME = os.getenv('VIMRUNTIME'),
- },
- })
+ funcs.termopen(
+ (
+ [[echo foo | ]]
+ .. [["%s" -u NONE -i NONE --cmd "%s"]]
+ .. [[ -c "echo has('ttyin') has('ttyout')"]]
+ ):format(nvim_prog, nvim_set),
+ {
+ env = {
+ VIMRUNTIME = os.getenv('VIMRUNTIME'),
+ },
+ }
+ )
screen:expect([[
^foo |
~ |
@@ -379,28 +452,44 @@ describe('startup', function()
end)
it('input from pipe + file args #7679', function()
- eq('ohyeah\r\n0 0 bufs=3',
- funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '--headless',
- '+.print',
- "+echo has('ttyin') has('ttyout') 'bufs='.bufnr('$')",
- '+qall!',
- '-',
- 'test/functional/fixtures/tty-test.c',
- 'test/functional/fixtures/shell-test.c',
- },
- { 'ohyeah', '' }))
+ eq(
+ 'ohyeah\r\n0 0 bufs=3',
+ funcs.system({
+ nvim_prog,
+ '-n',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--headless',
+ '+.print',
+ "+echo has('ttyin') has('ttyout') 'bufs='.bufnr('$')",
+ '+qall!',
+ '-',
+ 'test/functional/fixtures/tty-test.c',
+ 'test/functional/fixtures/shell-test.c',
+ }, { 'ohyeah', '' })
+ )
end)
it('if stdin is empty: selects buffer 2, deletes buffer 1 #8561', function()
- eq('\r\n 2 %a "file1" line 0\r\n 3 "file2" line 0',
- funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '--headless',
- '+ls!',
- '+qall!',
- '-',
- 'file1',
- 'file2',
- },
- { '' }))
+ eq(
+ '\r\n 2 %a "file1" line 0\r\n 3 "file2" line 0',
+ funcs.system({
+ nvim_prog,
+ '-n',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--headless',
+ '+ls!',
+ '+qall!',
+ '-',
+ 'file1',
+ 'file2',
+ }, { '' })
+ )
end)
it('stdin with -es/-Es #7679', function()
@@ -410,48 +499,70 @@ describe('startup', function()
--
-- -Es: read stdin as text
--
- eq('partylikeits1999\n',
- funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '-Es', '+.print', 'test/functional/fixtures/tty-test.c' },
- { 'partylikeits1999', '' }))
- eq(inputstr,
- funcs.system({nvim_prog, '-i', 'NONE', '-Es', '+%print', '-' },
- input))
+ eq(
+ 'partylikeits1999\n',
+ funcs.system({
+ nvim_prog,
+ '-n',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '-Es',
+ '+.print',
+ 'test/functional/fixtures/tty-test.c',
+ }, { 'partylikeits1999', '' })
+ )
+ eq(inputstr, funcs.system({ nvim_prog, '-i', 'NONE', '-Es', '+%print', '-' }, input))
-- with `-u NORC`
- eq('thepartycontinues\n',
- funcs.system({nvim_prog, '-n', '-u', 'NORC', '-Es', '+.print' },
- { 'thepartycontinues', '' }))
+ eq(
+ 'thepartycontinues\n',
+ funcs.system({ nvim_prog, '-n', '-u', 'NORC', '-Es', '+.print' }, { 'thepartycontinues', '' })
+ )
-- without `-u`
- eq('thepartycontinues\n',
- funcs.system({nvim_prog, '-n', '-Es', '+.print' },
- { 'thepartycontinues', '' }))
+ eq(
+ 'thepartycontinues\n',
+ funcs.system({ nvim_prog, '-n', '-Es', '+.print' }, { 'thepartycontinues', '' })
+ )
--
-- -es: read stdin as ex-commands
--
- eq(' encoding=utf-8\n',
- funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '-es', 'test/functional/fixtures/tty-test.c' },
- { 'set encoding', '' }))
- eq('line1\nline2\n',
- funcs.system({nvim_prog, '-i', 'NONE', '-es', '-' },
- input))
+ eq(
+ ' encoding=utf-8\n',
+ funcs.system({
+ nvim_prog,
+ '-n',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '-es',
+ 'test/functional/fixtures/tty-test.c',
+ }, { 'set encoding', '' })
+ )
+ eq('line1\nline2\n', funcs.system({ nvim_prog, '-i', 'NONE', '-es', '-' }, input))
-- with `-u NORC`
- eq(' encoding=utf-8\n',
- funcs.system({nvim_prog, '-n', '-u', 'NORC', '-es' },
- { 'set encoding', '' }))
+ eq(
+ ' encoding=utf-8\n',
+ funcs.system({ nvim_prog, '-n', '-u', 'NORC', '-es' }, { 'set encoding', '' })
+ )
-- without `-u`
- eq(' encoding=utf-8\n',
- funcs.system({nvim_prog, '-n', '-es' },
- { 'set encoding', '' }))
+ eq(' encoding=utf-8\n', funcs.system({ nvim_prog, '-n', '-es' }, { 'set encoding', '' }))
end)
it('-es/-Es disables swapfile, user config #8540', function()
- for _,arg in ipairs({'-es', '-Es'}) do
- local out = funcs.system({nvim_prog, arg,
- '+set swapfile? updatecount? shadafile?',
- "+put =map(getscriptinfo(), {-> v:val.name})", '+%print'})
+ for _, arg in ipairs({ '-es', '-Es' }) do
+ local out = funcs.system({
+ nvim_prog,
+ arg,
+ '+set swapfile? updatecount? shadafile?',
+ '+put =map(getscriptinfo(), {-> v:val.name})',
+ '+%print',
+ })
local line1 = string.match(out, '^.-\n')
-- updatecount=0 means swapfile was disabled.
- eq(" swapfile updatecount=0 shadafile=\n", line1)
+ eq(' swapfile updatecount=0 shadafile=\n', line1)
-- Standard plugins were loaded, but not user config.
ok(string.find(out, 'man.lua') ~= nil)
ok(string.find(out, 'init.vim') == nil)
@@ -459,12 +570,18 @@ describe('startup', function()
end)
it('fails on --embed with -es/-Es/-l', function()
- matches('nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l',
- funcs.system({nvim_prog, '--embed', '-es' }))
- matches('nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l',
- funcs.system({nvim_prog, '--embed', '-Es' }))
- matches('nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l',
- funcs.system({nvim_prog, '--embed', '-l', 'foo.lua' }))
+ matches(
+ 'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l',
+ funcs.system({ nvim_prog, '--embed', '-es' })
+ )
+ matches(
+ 'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l',
+ funcs.system({ nvim_prog, '--embed', '-Es' })
+ )
+ matches(
+ 'nvim[.exe]*: %-%-embed conflicts with %-es/%-Es/%-l',
+ funcs.system({ nvim_prog, '--embed', '-l', 'foo.lua' })
+ )
end)
it('ENTER dismisses early message #7967', function()
@@ -473,10 +590,14 @@ describe('startup', function()
screen:attach()
local id = funcs.termopen({
nvim_prog,
- '-u', 'NONE',
- '-i', 'NONE',
- '--cmd', 'set noruler',
- '--cmd', 'let g:foo = g:bar',
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--cmd',
+ 'set noruler',
+ '--cmd',
+ 'let g:foo = g:bar',
}, {
env = {
VIMRUNTIME = os.getenv('VIMRUNTIME'),
@@ -530,19 +651,32 @@ describe('startup', function()
expected,
-- FIXME(codehex): We should really set a timeout for the system function.
-- If this test fails, there will be a waiting input state.
- funcs.system({nvim_prog, '-u', 'NONE', '-c',
+ funcs.system({
+ nvim_prog,
+ '-u',
+ 'NONE',
+ '-c',
'for i in range(1, 100) | echo i | endfor | quit',
- '--headless'
+ '--headless',
})
)
end)
- it("get command line arguments from v:argv", function()
- local out = funcs.system({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless',
- '--cmd', nvim_set,
- '-c', [[echo v:argv[-1:] len(v:argv) > 1]],
- '+q' })
- eq('[\'+q\'] 1', out)
+ it('get command line arguments from v:argv', function()
+ local out = funcs.system({
+ nvim_prog,
+ '-u',
+ 'NONE',
+ '-i',
+ 'NONE',
+ '--headless',
+ '--cmd',
+ nvim_set,
+ '-c',
+ [[echo v:argv[-1:] len(v:argv) > 1]],
+ '+q',
+ })
+ eq("['+q'] 1", out)
end)
end)
@@ -574,20 +708,20 @@ describe('startup', function()
clear('-e')
screen:attach()
-- Verify we set the proper mode both before and after :vi.
- feed("put =mode(1)<CR>vi<CR>:put =mode(1)<CR>")
+ feed('put =mode(1)<CR>vi<CR>:put =mode(1)<CR>')
screen:expect([[
cv |
^n |
:put =mode(1) |
]])
- eq('cv\n',
- funcs.system({nvim_prog, '-n', '-es' },
- { 'put =mode(1)', 'print', '' }))
+ eq('cv\n', funcs.system({ nvim_prog, '-n', '-es' }, { 'put =mode(1)', 'print', '' }))
end)
it('-d does not diff non-arglist windows #13720 #21289', function()
- write_file('Xdiff.vim', [[
+ write_file(
+ 'Xdiff.vim',
+ [[
let bufnr = nvim_create_buf(0, 1)
let config = {
\ 'relative': 'editor',
@@ -597,78 +731,92 @@ describe('startup', function()
\ 'row': 3,
\ 'col': 3
\ }
- autocmd WinEnter * call nvim_open_win(bufnr, v:false, config)]])
+ autocmd WinEnter * call nvim_open_win(bufnr, v:false, config)]]
+ )
finally(function()
os.remove('Xdiff.vim')
end)
- clear{args={'-u', 'Xdiff.vim', '-d', 'Xdiff.vim', 'Xdiff.vim'}}
- eq(true, meths.get_option_value('diff', {win = funcs.win_getid(1)}))
- eq(true, meths.get_option_value('diff', {win = funcs.win_getid(2)}))
+ clear { args = { '-u', 'Xdiff.vim', '-d', 'Xdiff.vim', 'Xdiff.vim' } }
+ eq(true, meths.get_option_value('diff', { win = funcs.win_getid(1) }))
+ eq(true, meths.get_option_value('diff', { win = funcs.win_getid(2) }))
local float_win = funcs.win_getid(3)
eq('editor', meths.win_get_config(float_win).relative)
- eq(false, meths.get_option_value('diff', {win = float_win}))
+ eq(false, meths.get_option_value('diff', { win = float_win }))
end)
it('does not crash if --embed is given twice', function()
- clear{args={'--embed'}}
+ clear { args = { '--embed' } }
assert_alive()
end)
it('does not crash when expanding cdpath during early_init', function()
- clear{env={CDPATH='~doesnotexist'}}
+ clear { env = { CDPATH = '~doesnotexist' } }
assert_alive()
eq(',~doesnotexist', eval('&cdpath'))
end)
it("sets 'shortmess' when loading other tabs", function()
- clear({args={'-p', 'a', 'b', 'c'}})
+ clear({ args = { '-p', 'a', 'b', 'c' } })
local screen = Screen.new(25, 4)
screen:attach()
- screen:expect({grid=[[
+ screen:expect({
+ grid = [[
{1: a }{2: b c }{3: }{2:X}|
^ |
{4:~ }|
|
]],
- attr_ids={
- [1] = {bold = true},
- [2] = {background = Screen.colors.LightGrey, underline = true},
- [3] = {reverse = true},
- [4] = {bold = true, foreground = Screen.colors.Blue1},
- }})
+ attr_ids = {
+ [1] = { bold = true },
+ [2] = { background = Screen.colors.LightGrey, underline = true },
+ [3] = { reverse = true },
+ [4] = { bold = true, foreground = Screen.colors.Blue1 },
+ },
+ })
end)
end)
describe('startup', function()
local function pack_clear(cmd)
-- add packages after config dir in rtp but before config/after
- clear{args={'--cmd', 'set packpath=test/functional/fixtures', '--cmd', 'let paths=split(&rtp, ",")', '--cmd', 'let &rtp = paths[0]..",test/functional/fixtures,test/functional/fixtures/middle,"..join(paths[1:],",")', '--cmd', cmd}, env={XDG_CONFIG_HOME='test/functional/fixtures/'},
- args_rm={'runtimepath'},
+ clear {
+ args = {
+ '--cmd',
+ 'set packpath=test/functional/fixtures',
+ '--cmd',
+ 'let paths=split(&rtp, ",")',
+ '--cmd',
+ 'let &rtp = paths[0]..",test/functional/fixtures,test/functional/fixtures/middle,"..join(paths[1:],",")',
+ '--cmd',
+ cmd,
+ },
+ env = { XDG_CONFIG_HOME = 'test/functional/fixtures/' },
+ args_rm = { 'runtimepath' },
}
end
- it("handles &packpath during startup", function()
+ it('handles &packpath during startup', function()
pack_clear [[
let g:x = bar#test()
let g:y = leftpad#pad("heyya")
]]
eq(-3, eval 'g:x')
- eq(" heyya", eval 'g:y')
+ eq(' heyya', eval 'g:y')
pack_clear [[ lua _G.y = require'bar'.doit() _G.z = require'leftpad''howdy' ]]
- eq({9003, '\thowdy'}, exec_lua [[ return { _G.y, _G.z } ]])
+ eq({ 9003, '\thowdy' }, exec_lua [[ return { _G.y, _G.z } ]])
end)
- it("handles require from &packpath in an async handler", function()
- -- NO! you cannot just speed things up by calling async functions during startup!
- -- It doesn't make anything actually faster! NOOOO!
+ it('handles require from &packpath in an async handler', function()
+ -- NO! you cannot just speed things up by calling async functions during startup!
+ -- It doesn't make anything actually faster! NOOOO!
pack_clear [[ lua require'async_leftpad'('brrrr', 'async_res') ]]
-- haha, async leftpad go brrrrr
eq('\tbrrrr', exec_lua [[ return _G.async_res ]])
end)
- it("handles :packadd during startup", function()
+ it('handles :packadd during startup', function()
-- control group: opt/bonus is not available by default
pack_clear [[
try
@@ -680,8 +828,10 @@ describe('startup', function()
eq('Vim(let):E117: Unknown function: bonus#secret', eval 'g:err')
pack_clear [[ lua _G.test = {pcall(function() require'bonus'.launch() end)} ]]
- eq({false, [[[string ":lua"]:1: module 'bonus' not found:]]},
- exec_lua [[ _G.test[2] = string.gsub(_G.test[2], '[\r\n].*', '') return _G.test ]])
+ eq(
+ { false, [[[string ":lua"]:1: module 'bonus' not found:]] },
+ exec_lua [[ _G.test[2] = string.gsub(_G.test[2], '[\r\n].*', '') return _G.test ]]
+ )
-- ok, time to launch the nukes:
pack_clear [[ packadd! bonus | let g:x = bonus#secret() ]]
@@ -691,46 +841,77 @@ describe('startup', function()
eq('CPE 1704 TKS', exec_lua [[ return _G.y ]])
end)
- it("handles the correct order with start packages and after/", function()
+ it('handles the correct order with start packages and after/', function()
pack_clear [[ lua _G.test_loadorder = {} vim.cmd "runtime! filen.lua" ]]
- eq({'ordinary', 'FANCY', 'mittel', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
+ eq(
+ { 'ordinary', 'FANCY', 'mittel', 'FANCY after', 'ordinary after' },
+ exec_lua [[ return _G.test_loadorder ]]
+ )
end)
- it("handles the correct order with start packages and after/ after startup", function()
+ it('handles the correct order with start packages and after/ after startup', function()
pack_clear [[ lua _G.test_loadorder = {} ]]
command [[ runtime! filen.lua ]]
- eq({'ordinary', 'FANCY', 'mittel', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
+ eq(
+ { 'ordinary', 'FANCY', 'mittel', 'FANCY after', 'ordinary after' },
+ exec_lua [[ return _G.test_loadorder ]]
+ )
end)
- it("handles the correct order with globpath(&rtp, ...)", function()
+ it('handles the correct order with globpath(&rtp, ...)', function()
pack_clear [[ set loadplugins | lua _G.test_loadorder = {} ]]
command [[
for x in globpath(&rtp, "filen.lua",1,1)
call v:lua.dofile(x)
endfor
]]
- eq({'ordinary', 'FANCY', 'mittel', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
+ eq(
+ { 'ordinary', 'FANCY', 'mittel', 'FANCY after', 'ordinary after' },
+ exec_lua [[ return _G.test_loadorder ]]
+ )
local rtp = meths.get_option_value('rtp', {})
- ok(startswith(rtp, 'test/functional/fixtures/nvim,test/functional/fixtures/pack/*/start/*,test/functional/fixtures/start/*,test/functional/fixtures,test/functional/fixtures/middle,'),
- 'startswith(…)', 'rtp='..rtp)
+ ok(
+ startswith(
+ rtp,
+ 'test/functional/fixtures/nvim,test/functional/fixtures/pack/*/start/*,test/functional/fixtures/start/*,test/functional/fixtures,test/functional/fixtures/middle,'
+ ),
+ 'startswith(…)',
+ 'rtp=' .. rtp
+ )
end)
- it("handles the correct order with opt packages and after/", function()
+ it('handles the correct order with opt packages and after/', function()
pack_clear [[ lua _G.test_loadorder = {} vim.cmd "packadd! superspecial\nruntime! filen.lua" ]]
- eq({'ordinary', 'SuperSpecial', 'FANCY', 'mittel', 'FANCY after', 'SuperSpecial after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
+ eq({
+ 'ordinary',
+ 'SuperSpecial',
+ 'FANCY',
+ 'mittel',
+ 'FANCY after',
+ 'SuperSpecial after',
+ 'ordinary after',
+ }, exec_lua [[ return _G.test_loadorder ]])
end)
- it("handles the correct order with opt packages and after/ after startup", function()
+ it('handles the correct order with opt packages and after/ after startup', function()
pack_clear [[ lua _G.test_loadorder = {} ]]
command [[
packadd! superspecial
runtime! filen.lua
]]
- eq({'ordinary', 'SuperSpecial', 'FANCY', 'mittel', 'FANCY after', 'SuperSpecial after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
+ eq({
+ 'ordinary',
+ 'SuperSpecial',
+ 'FANCY',
+ 'mittel',
+ 'FANCY after',
+ 'SuperSpecial after',
+ 'ordinary after',
+ }, exec_lua [[ return _G.test_loadorder ]])
end)
- it("handles the correct order with opt packages and globpath(&rtp, ...)", function()
+ it('handles the correct order with opt packages and globpath(&rtp, ...)', function()
pack_clear [[ set loadplugins | lua _G.test_loadorder = {} ]]
command [[
packadd! superspecial
@@ -738,18 +919,40 @@ describe('startup', function()
call v:lua.dofile(x)
endfor
]]
- eq({'ordinary', 'SuperSpecial', 'FANCY', 'mittel', 'SuperSpecial after', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
+ eq({
+ 'ordinary',
+ 'SuperSpecial',
+ 'FANCY',
+ 'mittel',
+ 'SuperSpecial after',
+ 'FANCY after',
+ 'ordinary after',
+ }, exec_lua [[ return _G.test_loadorder ]])
end)
- it("handles the correct order with a package that changes packpath", function()
+ it('handles the correct order with a package that changes packpath', function()
pack_clear [[ lua _G.test_loadorder = {} vim.cmd "packadd! funky\nruntime! filen.lua" ]]
- eq({'ordinary', 'funky!', 'FANCY', 'mittel', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
- eq({'ordinary', 'funky!', 'mittel', 'ordinary after'}, exec_lua [[ return _G.nested_order ]])
+ eq(
+ { 'ordinary', 'funky!', 'FANCY', 'mittel', 'FANCY after', 'ordinary after' },
+ exec_lua [[ return _G.test_loadorder ]]
+ )
+ eq({ 'ordinary', 'funky!', 'mittel', 'ordinary after' }, exec_lua [[ return _G.nested_order ]])
end)
- it("handles the correct order when prepending packpath", function()
- clear{args={'--cmd', 'set packpath^=test/functional/fixtures', '--cmd', [[ lua _G.test_loadorder = {} vim.cmd "runtime! filen.lua" ]]}, env={XDG_CONFIG_HOME='test/functional/fixtures/'}}
- eq({'ordinary', 'FANCY', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
+ it('handles the correct order when prepending packpath', function()
+ clear {
+ args = {
+ '--cmd',
+ 'set packpath^=test/functional/fixtures',
+ '--cmd',
+ [[ lua _G.test_loadorder = {} vim.cmd "runtime! filen.lua" ]],
+ },
+ env = { XDG_CONFIG_HOME = 'test/functional/fixtures/' },
+ }
+ eq(
+ { 'ordinary', 'FANCY', 'FANCY after', 'ordinary after' },
+ exec_lua [[ return _G.test_loadorder ]]
+ )
end)
it('window widths are correct when modelines set &columns with tabpages', function()
@@ -759,7 +962,7 @@ describe('startup', function()
os.remove('Xtab1.noft')
os.remove('Xtab2.noft')
end)
- clear({args = {'-p', 'Xtab1.noft', 'Xtab2.noft'}})
+ clear({ args = { '-p', 'Xtab1.noft', 'Xtab2.noft' } })
eq(81, meths.win_get_width(0))
command('tabnext')
eq(81, meths.win_get_width(0))
@@ -779,16 +982,22 @@ describe('sysinit', function()
mkdir(xdgdir)
mkdir(xdgdir .. pathsep .. 'nvim')
- write_file(table.concat({xdgdir, 'nvim', 'sysinit.vim'}, pathsep), [[
+ write_file(
+ table.concat({ xdgdir, 'nvim', 'sysinit.vim' }, pathsep),
+ [[
let g:loaded = get(g:, "loaded", 0) + 1
let g:xdg = 1
- ]])
+ ]]
+ )
mkdir(vimdir)
- write_file(table.concat({vimdir, 'sysinit.vim'}, pathsep), [[
+ write_file(
+ table.concat({ vimdir, 'sysinit.vim' }, pathsep),
+ [[
let g:loaded = get(g:, "loaded", 0) + 1
let g:vim = 1
- ]])
+ ]]
+ )
mkdir(xhome)
end)
@@ -799,23 +1008,27 @@ describe('sysinit', function()
end)
it('prefers XDG_CONFIG_DIRS over VIM', function()
- clear{args={'--cmd', 'set nomore undodir=. directory=. belloff='},
- args_rm={'-u', '--cmd'},
- env={ HOME=xhome,
- XDG_CONFIG_DIRS=xdgdir,
- VIM=vimdir }}
- eq('loaded 1 xdg 1 vim 0',
- eval('printf("loaded %d xdg %d vim %d", g:loaded, get(g:, "xdg", 0), get(g:, "vim", 0))'))
+ clear {
+ args = { '--cmd', 'set nomore undodir=. directory=. belloff=' },
+ args_rm = { '-u', '--cmd' },
+ env = { HOME = xhome, XDG_CONFIG_DIRS = xdgdir, VIM = vimdir },
+ }
+ eq(
+ 'loaded 1 xdg 1 vim 0',
+ eval('printf("loaded %d xdg %d vim %d", g:loaded, get(g:, "xdg", 0), get(g:, "vim", 0))')
+ )
end)
it('uses VIM if XDG_CONFIG_DIRS unset', function()
- clear{args={'--cmd', 'set nomore undodir=. directory=. belloff='},
- args_rm={'-u', '--cmd'},
- env={ HOME=xhome,
- XDG_CONFIG_DIRS='',
- VIM=vimdir }}
- eq('loaded 1 xdg 0 vim 1',
- eval('printf("loaded %d xdg %d vim %d", g:loaded, get(g:, "xdg", 0), get(g:, "vim", 0))'))
+ clear {
+ args = { '--cmd', 'set nomore undodir=. directory=. belloff=' },
+ args_rm = { '-u', '--cmd' },
+ env = { HOME = xhome, XDG_CONFIG_DIRS = '', VIM = vimdir },
+ }
+ eq(
+ 'loaded 1 xdg 0 vim 1',
+ eval('printf("loaded %d xdg %d vim %d", g:loaded, get(g:, "xdg", 0), get(g:, "vim", 0))')
+ )
end)
end)
@@ -824,8 +1037,8 @@ describe('user config init', function()
local pathsep = helpers.get_pathsep()
local xconfig = xhome .. pathsep .. 'Xconfig'
local xdata = xhome .. pathsep .. 'Xdata'
- local init_lua_path = table.concat({xconfig, 'nvim', 'init.lua'}, pathsep)
- local xenv = { XDG_CONFIG_HOME=xconfig, XDG_DATA_HOME=xdata }
+ local init_lua_path = table.concat({ xconfig, 'nvim', 'init.lua' }, pathsep)
+ local xenv = { XDG_CONFIG_HOME = xconfig, XDG_DATA_HOME = xdata }
before_each(function()
rmdir(xhome)
@@ -833,9 +1046,12 @@ describe('user config init', function()
mkdir_p(xconfig .. pathsep .. 'nvim')
mkdir_p(xdata)
- write_file(init_lua_path, [[
+ write_file(
+ init_lua_path,
+ [[
vim.g.lua_rc = 1
- ]])
+ ]]
+ )
end)
after_each(function()
@@ -843,7 +1059,7 @@ describe('user config init', function()
end)
it('loads init.lua from XDG config home by default', function()
- clear{ args_rm={'-u'}, env=xenv }
+ clear { args_rm = { '-u' }, env = xenv }
eq(1, eval('g:lua_rc'))
eq(funcs.fnamemodify(init_lua_path, ':p'), eval('$MYVIMRC'))
@@ -852,27 +1068,42 @@ describe('user config init', function()
describe('loads existing', function()
local exrc_path = '.exrc'
local xstate = 'Xstate'
- local xstateenv = { XDG_CONFIG_HOME=xconfig, XDG_DATA_HOME=xdata, XDG_STATE_HOME=xstate }
+ local xstateenv = { XDG_CONFIG_HOME = xconfig, XDG_DATA_HOME = xdata, XDG_STATE_HOME = xstate }
local function setup_exrc_file(filename)
exrc_path = filename
- if string.find(exrc_path, "%.lua$") then
- write_file(exrc_path, string.format([[
+ if string.find(exrc_path, '%.lua$') then
+ write_file(
+ exrc_path,
+ string.format(
+ [[
vim.g.exrc_file = "%s"
- ]], exrc_path))
+ ]],
+ exrc_path
+ )
+ )
else
- write_file(exrc_path, string.format([[
+ write_file(
+ exrc_path,
+ string.format(
+ [[
let g:exrc_file = "%s"
- ]], exrc_path))
+ ]],
+ exrc_path
+ )
+ )
end
end
before_each(function()
- write_file(init_lua_path, [[
+ write_file(
+ init_lua_path,
+ [[
vim.o.exrc = true
vim.g.exrc_file = '---'
- ]])
+ ]]
+ )
mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
end)
@@ -885,13 +1116,13 @@ describe('user config init', function()
it(filename .. ' in cwd', function()
setup_exrc_file(filename)
- clear{ args_rm={'-u'}, env=xstateenv }
+ clear { args_rm = { '-u' }, env = xstateenv }
-- The 'exrc' file is not trusted, and the prompt is skipped because there is no UI.
eq('---', eval('g:exrc_file'))
local screen = Screen.new(50, 8)
screen:attach()
- funcs.termopen({nvim_prog}, {
+ funcs.termopen({ nvim_prog }, {
env = {
VIMRUNTIME = os.getenv('VIMRUNTIME'),
},
@@ -907,15 +1138,19 @@ describe('user config init', function()
-- TERMINAL -- |
]])
feed(':echo g:exrc_file<CR>')
- screen:expect(string.format([[
+ screen:expect(string.format(
+ [[
|
~ |*4
[No Name] 0,0-1 All|
%s%s|
-- TERMINAL -- |
- ]], filename, string.rep(' ', 50 - #filename)))
+ ]],
+ filename,
+ string.rep(' ', 50 - #filename)
+ ))
- clear{ args_rm={'-u'}, env=xstateenv }
+ clear { args_rm = { '-u' }, env = xstateenv }
-- The 'exrc' file is now trusted.
eq(filename, eval('g:exrc_file'))
end)
@@ -923,15 +1158,18 @@ describe('user config init', function()
end)
describe('with explicitly provided config', function()
- local custom_lua_path = table.concat({xhome, 'custom.lua'}, pathsep)
+ local custom_lua_path = table.concat({ xhome, 'custom.lua' }, pathsep)
before_each(function()
- write_file(custom_lua_path, [[
+ write_file(
+ custom_lua_path,
+ [[
vim.g.custom_lua_rc = 1
- ]])
+ ]]
+ )
end)
it('loads custom lua config and does not set $MYVIMRC', function()
- clear{ args={'-u', custom_lua_path }, env=xenv }
+ clear { args = { '-u', custom_lua_path }, env = xenv }
eq(1, eval('g:custom_lua_rc'))
eq('', eval('$MYVIMRC'))
end)
@@ -939,14 +1177,17 @@ describe('user config init', function()
describe('VIMRC also exists', function()
before_each(function()
- write_file(table.concat({xconfig, 'nvim', 'init.vim'}, pathsep), [[
+ write_file(
+ table.concat({ xconfig, 'nvim', 'init.vim' }, pathsep),
+ [[
let g:vim_rc = 1
- ]])
+ ]]
+ )
end)
it('loads default lua config, but shows an error', function()
- clear{ args_rm={'-u'}, env=xenv }
- feed('<cr><c-c>') -- Dismiss "Conflicting config …" message.
+ clear { args_rm = { '-u' }, env = xenv }
+ feed('<cr><c-c>') -- Dismiss "Conflicting config …" message.
eq(1, eval('g:lua_rc'))
matches('^E5422: Conflicting configs', exec_capture('messages'))
end)
@@ -958,7 +1199,7 @@ describe('runtime:', function()
local pathsep = helpers.get_pathsep()
local xconfig = xhome .. pathsep .. 'Xconfig'
local xdata = xhome .. pathsep .. 'Xdata'
- local xenv = { XDG_CONFIG_HOME=xconfig, XDG_DATA_HOME=xdata }
+ local xenv = { XDG_CONFIG_HOME = xconfig, XDG_DATA_HOME = xdata }
setup(function()
rmdir(xhome)
@@ -971,23 +1212,24 @@ describe('runtime:', function()
end)
it('loads plugin/*.lua from XDG config home', function()
- local plugin_folder_path = table.concat({xconfig, 'nvim', 'plugin'}, pathsep)
- local plugin_file_path = table.concat({plugin_folder_path, 'plugin.lua'}, pathsep)
+ local plugin_folder_path = table.concat({ xconfig, 'nvim', 'plugin' }, pathsep)
+ local plugin_file_path = table.concat({ plugin_folder_path, 'plugin.lua' }, pathsep)
mkdir_p(plugin_folder_path)
finally(function()
rmdir(plugin_folder_path)
end)
write_file(plugin_file_path, [[ vim.g.lua_plugin = 1 ]])
- clear{ args_rm={'-u'}, env=xenv }
+ clear { args_rm = { '-u' }, env = xenv }
eq(1, eval('g:lua_plugin'))
end)
it('loads plugin/*.lua from start packages', function()
- local plugin_path = table.concat({xconfig, 'nvim', 'pack', 'category', 'start', 'test_plugin'}, pathsep)
- local plugin_folder_path = table.concat({plugin_path, 'plugin'}, pathsep)
- local plugin_file_path = table.concat({plugin_folder_path, 'plugin.lua'}, pathsep)
+ local plugin_path =
+ table.concat({ xconfig, 'nvim', 'pack', 'category', 'start', 'test_plugin' }, pathsep)
+ local plugin_folder_path = table.concat({ plugin_path, 'plugin' }, pathsep)
+ local plugin_file_path = table.concat({ plugin_folder_path, 'plugin.lua' }, pathsep)
local profiler_file = 'test_startuptime.log'
mkdir_p(plugin_folder_path)
finally(function()
@@ -997,12 +1239,16 @@ describe('runtime:', function()
write_file(plugin_file_path, [[vim.g.lua_plugin = 2]])
- clear{ args_rm={'-u'}, args={'--startuptime', profiler_file}, env=xenv }
+ clear { args_rm = { '-u' }, args = { '--startuptime', profiler_file }, env = xenv }
eq(2, eval('g:lua_plugin'))
-- Check if plugin_file_path is listed in getscriptinfo()
- local scripts = tbl_map(function(s) return s.name end, funcs.getscriptinfo())
- ok(#tbl_filter(function(s) return endswith(s, plugin_file_path) end, scripts) > 0)
+ local scripts = tbl_map(function(s)
+ return s.name
+ end, funcs.getscriptinfo())
+ ok(#tbl_filter(function(s)
+ return endswith(s, plugin_file_path)
+ end, scripts) > 0)
-- Check if plugin_file_path is listed in startup profile
local profile_reader = io.open(profiler_file, 'r')
@@ -1012,12 +1258,13 @@ describe('runtime:', function()
end)
it('loads plugin/*.lua from site packages', function()
- local nvimdata = is_os('win') and "nvim-data" or "nvim"
- local plugin_path = table.concat({xdata, nvimdata, 'site', 'pack', 'xa', 'start', 'yb'}, pathsep)
- local plugin_folder_path = table.concat({plugin_path, 'plugin'}, pathsep)
- local plugin_after_path = table.concat({plugin_path, 'after', 'plugin'}, pathsep)
- local plugin_file_path = table.concat({plugin_folder_path, 'plugin.lua'}, pathsep)
- local plugin_after_file_path = table.concat({plugin_after_path, 'helloo.lua'}, pathsep)
+ local nvimdata = is_os('win') and 'nvim-data' or 'nvim'
+ local plugin_path =
+ table.concat({ xdata, nvimdata, 'site', 'pack', 'xa', 'start', 'yb' }, pathsep)
+ local plugin_folder_path = table.concat({ plugin_path, 'plugin' }, pathsep)
+ local plugin_after_path = table.concat({ plugin_path, 'after', 'plugin' }, pathsep)
+ local plugin_file_path = table.concat({ plugin_folder_path, 'plugin.lua' }, pathsep)
+ local plugin_after_file_path = table.concat({ plugin_after_path, 'helloo.lua' }, pathsep)
mkdir_p(plugin_folder_path)
mkdir_p(plugin_after_path)
finally(function()
@@ -1027,49 +1274,64 @@ describe('runtime:', function()
write_file(plugin_file_path, [[table.insert(_G.lista, "unos")]])
write_file(plugin_after_file_path, [[table.insert(_G.lista, "dos")]])
- clear{ args_rm={'-u'}, args={'--cmd', 'lua _G.lista = {}'}, env=xenv }
+ clear { args_rm = { '-u' }, args = { '--cmd', 'lua _G.lista = {}' }, env = xenv }
- eq({'unos', 'dos'}, exec_lua "return _G.lista")
+ eq({ 'unos', 'dos' }, exec_lua 'return _G.lista')
end)
it('no crash setting &rtp in plugins with :packloadall called before #18315', function()
- local plugin_folder_path = table.concat({xconfig, 'nvim', 'plugin'}, pathsep)
+ local plugin_folder_path = table.concat({ xconfig, 'nvim', 'plugin' }, pathsep)
mkdir_p(plugin_folder_path)
finally(function()
rmdir(plugin_folder_path)
end)
- write_file(table.concat({plugin_folder_path, 'plugin.vim'}, pathsep), [[
+ write_file(
+ table.concat({ plugin_folder_path, 'plugin.vim' }, pathsep),
+ [[
let &runtimepath = &runtimepath
let g:vim_plugin = 1
- ]])
- write_file(table.concat({plugin_folder_path, 'plugin.lua'}, pathsep), [[
+ ]]
+ )
+ write_file(
+ table.concat({ plugin_folder_path, 'plugin.lua' }, pathsep),
+ [[
vim.o.runtimepath = vim.o.runtimepath
vim.g.lua_plugin = 1
- ]])
+ ]]
+ )
- clear{ args_rm={'-u'}, args = {'--cmd', 'packloadall'}, env=xenv }
+ clear { args_rm = { '-u' }, args = { '--cmd', 'packloadall' }, env = xenv }
eq(1, eval('g:vim_plugin'))
eq(1, eval('g:lua_plugin'))
end)
it("loads ftdetect/*.{vim,lua} respecting 'rtp' order", function()
- local ftdetect_folder = table.concat({xconfig, 'nvim', 'ftdetect'}, pathsep)
- local after_ftdetect_folder = table.concat({xconfig, 'nvim', 'after', 'ftdetect'}, pathsep)
+ local ftdetect_folder = table.concat({ xconfig, 'nvim', 'ftdetect' }, pathsep)
+ local after_ftdetect_folder = table.concat({ xconfig, 'nvim', 'after', 'ftdetect' }, pathsep)
mkdir_p(ftdetect_folder)
mkdir_p(after_ftdetect_folder)
finally(function()
rmdir(ftdetect_folder)
rmdir(after_ftdetect_folder)
end)
- -- A .lua file is loaded after a .vim file if they only differ in extension.
- -- All files in after/ftdetect/ are loaded after all files in ftdetect/.
- write_file(table.concat({ftdetect_folder, 'new-ft.vim'}, pathsep), [[let g:seq ..= 'A']])
- write_file(table.concat({ftdetect_folder, 'new-ft.lua'}, pathsep), [[vim.g.seq = vim.g.seq .. 'B']])
- write_file(table.concat({after_ftdetect_folder, 'new-ft.vim'}, pathsep), [[let g:seq ..= 'a']])
- write_file(table.concat({after_ftdetect_folder, 'new-ft.lua'}, pathsep), [[vim.g.seq = vim.g.seq .. 'b']])
- clear{ args_rm={'-u'}, args = {'--cmd', 'let g:seq = ""'}, env=xenv }
+ -- A .lua file is loaded after a .vim file if they only differ in extension.
+ -- All files in after/ftdetect/ are loaded after all files in ftdetect/.
+ write_file(table.concat({ ftdetect_folder, 'new-ft.vim' }, pathsep), [[let g:seq ..= 'A']])
+ write_file(
+ table.concat({ ftdetect_folder, 'new-ft.lua' }, pathsep),
+ [[vim.g.seq = vim.g.seq .. 'B']]
+ )
+ write_file(
+ table.concat({ after_ftdetect_folder, 'new-ft.vim' }, pathsep),
+ [[let g:seq ..= 'a']]
+ )
+ write_file(
+ table.concat({ after_ftdetect_folder, 'new-ft.lua' }, pathsep),
+ [[vim.g.seq = vim.g.seq .. 'b']]
+ )
+ clear { args_rm = { '-u' }, args = { '--cmd', 'let g:seq = ""' }, env = xenv }
eq('ABab', eval('g:seq'))
end)
end)
@@ -1077,15 +1339,18 @@ end)
describe('user session', function()
local xhome = 'Xhome'
local pathsep = helpers.get_pathsep()
- local session_file = table.concat({xhome, 'session.lua'}, pathsep)
+ local session_file = table.concat({ xhome, 'session.lua' }, pathsep)
before_each(function()
rmdir(xhome)
mkdir(xhome)
- write_file(session_file, [[
+ write_file(
+ session_file,
+ [[
vim.g.lua_session = 1
- ]])
+ ]]
+ )
end)
after_each(function()
@@ -1093,7 +1358,7 @@ describe('user session', function()
end)
it('loads session from the provided lua file', function()
- clear{ args={'-S', session_file }, env={ HOME=xhome }}
+ clear { args = { '-S', session_file }, env = { HOME = xhome } }
eq(1, eval('g:lua_session'))
end)
end)
@@ -1104,18 +1369,27 @@ describe('inccommand on ex mode', function()
local screen
screen = Screen.new(60, 10)
screen:attach()
- local id = funcs.termopen({ nvim_prog, '-u', 'NONE', '-c', 'set termguicolors', '-E', 'test/README.md' }, {
- env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }
- })
+ local id = funcs.termopen(
+ { nvim_prog, '-u', 'NONE', '-c', 'set termguicolors', '-E', 'test/README.md' },
+ {
+ env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
+ }
+ )
funcs.chansend(id, '%s/N')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:^ }|
{1: }|*6
{1:Entering Ex mode. Type "visual" to go to Normal mode. }|
{1::%s/N }|
|
- ]], attr_ids={
- [1] = {background = Screen.colors.NvimDarkGrey2, foreground = Screen.colors.NvimLightGrey2};
- }}
+ ]],
+ attr_ids = {
+ [1] = {
+ background = Screen.colors.NvimDarkGrey2,
+ foreground = Screen.colors.NvimLightGrey2,
+ },
+ },
+ }
end)
end)