2021-06-01 20:32:37 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
|
|
|
|
local clear = helpers.clear
|
|
|
|
local eq = helpers.eq
|
|
|
|
local eval = helpers.eval
|
|
|
|
local exec = helpers.exec
|
2024-01-12 10:59:57 -07:00
|
|
|
local fn = helpers.fn
|
2021-06-01 20:32:37 -07:00
|
|
|
local mkdir_p = helpers.mkdir_p
|
|
|
|
local rmdir = helpers.rmdir
|
|
|
|
local write_file = helpers.write_file
|
|
|
|
|
|
|
|
describe('runtime:', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local plug_dir = 'Test_Plugin'
|
|
|
|
local sep = helpers.get_pathsep()
|
|
|
|
local init = 'dummy_init.lua'
|
|
|
|
|
|
|
|
setup(function()
|
|
|
|
io.open(init, 'w'):close() -- touch init file
|
|
|
|
clear { args = { '-u', init } }
|
|
|
|
exec('set rtp+=' .. plug_dir)
|
2023-07-08 08:29:24 -07:00
|
|
|
exec([[
|
2023-07-13 15:46:16 -07:00
|
|
|
set shell=doesnotexist
|
2023-07-08 08:29:24 -07:00
|
|
|
set completeslash=slash
|
|
|
|
set isfname+=(,)
|
|
|
|
]])
|
2021-06-01 20:32:37 -07:00
|
|
|
end)
|
|
|
|
|
2021-06-02 09:46:25 -07:00
|
|
|
teardown(function()
|
|
|
|
os.remove(init)
|
2021-06-01 20:32:37 -07:00
|
|
|
end)
|
|
|
|
|
2021-06-02 09:46:25 -07:00
|
|
|
before_each(function()
|
|
|
|
mkdir_p(plug_dir)
|
|
|
|
end)
|
2021-06-01 20:32:37 -07:00
|
|
|
|
2021-06-02 09:46:25 -07:00
|
|
|
after_each(function()
|
|
|
|
rmdir(plug_dir)
|
2023-01-21 20:19:58 -07:00
|
|
|
exec('bwipe!')
|
2021-06-01 20:32:37 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
describe('colors', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local colorscheme_folder = plug_dir .. sep .. 'colors'
|
2023-03-17 18:55:08 -07:00
|
|
|
before_each(function()
|
|
|
|
mkdir_p(colorscheme_folder)
|
|
|
|
end)
|
2021-06-02 09:46:25 -07:00
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
it('lua colorschemes work and are included in cmdline completion', function()
|
|
|
|
local colorscheme_file = table.concat({ colorscheme_folder, 'new_colorscheme.lua' }, sep)
|
2021-06-01 20:32:37 -07:00
|
|
|
write_file(colorscheme_file, [[vim.g.lua_colorscheme = 1]])
|
|
|
|
|
2024-01-12 10:59:57 -07:00
|
|
|
eq({ 'new_colorscheme' }, fn.getcompletion('new_c', 'color'))
|
|
|
|
eq({ 'colors/new_colorscheme.lua' }, fn.getcompletion('colors/new_c', 'runtime'))
|
2023-01-21 20:19:58 -07:00
|
|
|
|
2021-06-01 20:32:37 -07:00
|
|
|
exec('colorscheme new_colorscheme')
|
|
|
|
|
|
|
|
eq(1, eval('g:lua_colorscheme'))
|
|
|
|
end)
|
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
it("'rtp'/'pp' order is respected", function()
|
2023-05-23 01:12:16 -07:00
|
|
|
local pack_dir = 'Test_Pack'
|
|
|
|
mkdir_p(pack_dir)
|
|
|
|
finally(function()
|
|
|
|
rmdir(pack_dir)
|
|
|
|
end)
|
|
|
|
exec('set pp+=' .. pack_dir)
|
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
local pack_opt_dir = table.concat({ pack_dir, 'pack', 'some_name', 'opt' }, sep)
|
|
|
|
local colors_opt_dir = table.concat({ pack_opt_dir, 'some_pack', 'colors' }, sep)
|
2023-05-23 01:12:16 -07:00
|
|
|
mkdir_p(colors_opt_dir)
|
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
local after_colorscheme_folder = table.concat({ plug_dir, 'after', 'colors' }, sep)
|
|
|
|
mkdir_p(after_colorscheme_folder)
|
|
|
|
exec('set rtp+=' .. plug_dir .. '/after')
|
2023-05-23 01:12:16 -07:00
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
write_file(
|
|
|
|
table.concat({ colors_opt_dir, 'new_colorscheme.lua' }, sep),
|
|
|
|
[[vim.g.colorscheme = 'lua_pp']]
|
|
|
|
)
|
2023-05-23 01:12:16 -07:00
|
|
|
exec('colorscheme new_colorscheme')
|
|
|
|
eq('lua_pp', eval('g:colorscheme'))
|
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
write_file(
|
|
|
|
table.concat({ colors_opt_dir, 'new_colorscheme.vim' }, sep),
|
|
|
|
[[let g:colorscheme = 'vim_pp']]
|
|
|
|
)
|
2023-05-23 01:12:16 -07:00
|
|
|
exec('colorscheme new_colorscheme')
|
|
|
|
eq('vim_pp', eval('g:colorscheme'))
|
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
write_file(
|
|
|
|
table.concat({ after_colorscheme_folder, 'new_colorscheme.lua' }, sep),
|
|
|
|
[[vim.g.colorscheme = 'lua_rtp_after']]
|
|
|
|
)
|
|
|
|
exec('colorscheme new_colorscheme')
|
|
|
|
eq('lua_rtp_after', eval('g:colorscheme'))
|
|
|
|
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_colorscheme_folder, 'new_colorscheme.vim' }, sep),
|
|
|
|
[[let g:colorscheme = 'vim_rtp_after']]
|
|
|
|
)
|
|
|
|
exec('colorscheme new_colorscheme')
|
|
|
|
eq('vim_rtp_after', eval('g:colorscheme'))
|
|
|
|
|
|
|
|
write_file(
|
|
|
|
table.concat({ colorscheme_folder, 'new_colorscheme.lua' }, sep),
|
|
|
|
[[vim.g.colorscheme = 'lua_rtp']]
|
|
|
|
)
|
2023-05-23 01:12:16 -07:00
|
|
|
exec('colorscheme new_colorscheme')
|
|
|
|
eq('lua_rtp', eval('g:colorscheme'))
|
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
write_file(
|
|
|
|
table.concat({ colorscheme_folder, 'new_colorscheme.vim' }, sep),
|
|
|
|
[[let g:colorscheme = 'vim_rtp']]
|
|
|
|
)
|
2023-05-23 01:12:16 -07:00
|
|
|
exec('colorscheme new_colorscheme')
|
|
|
|
eq('vim_rtp', eval('g:colorscheme'))
|
|
|
|
end)
|
2021-06-01 20:32:37 -07:00
|
|
|
end)
|
|
|
|
|
2021-06-02 00:48:13 -07:00
|
|
|
describe('compiler', function()
|
2023-07-13 15:46:16 -07:00
|
|
|
local compiler_folder = table.concat({ plug_dir, 'compiler' }, sep)
|
2023-03-17 18:55:08 -07:00
|
|
|
before_each(function()
|
|
|
|
mkdir_p(compiler_folder)
|
|
|
|
end)
|
2021-06-02 00:48:13 -07:00
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
it('lua compilers work and are included in cmdline completion', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local compiler_file = compiler_folder .. sep .. 'new_compiler.lua'
|
2023-01-21 20:19:58 -07:00
|
|
|
write_file(compiler_file, [[vim.b.lua_compiler = 1]])
|
|
|
|
|
2024-01-12 10:59:57 -07:00
|
|
|
eq({ 'new_compiler' }, fn.getcompletion('new_c', 'compiler'))
|
|
|
|
eq({ 'compiler/new_compiler.lua' }, fn.getcompletion('compiler/new_c', 'runtime'))
|
2021-06-02 00:48:13 -07:00
|
|
|
|
|
|
|
exec('compiler new_compiler')
|
|
|
|
|
2023-01-21 20:19:58 -07:00
|
|
|
eq(1, eval('b:lua_compiler'))
|
2021-06-02 00:48:13 -07:00
|
|
|
end)
|
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
it("'rtp' order is respected", function()
|
|
|
|
local after_compiler_folder = table.concat({ plug_dir, 'after', 'compiler' }, sep)
|
|
|
|
mkdir_p(table.concat({ compiler_folder, 'new_compiler' }, sep))
|
|
|
|
mkdir_p(table.concat({ after_compiler_folder, 'new_compiler' }, sep))
|
|
|
|
exec('set rtp+=' .. plug_dir .. '/after')
|
|
|
|
exec('let g:seq = ""')
|
|
|
|
-- A .lua file is loaded after a .vim file if they only differ in extension.
|
|
|
|
-- All files in after/compiler/ are loaded after all files in compiler/.
|
|
|
|
write_file(table.concat({ compiler_folder, 'new_compiler.vim' }, sep), [[let g:seq ..= 'A']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ compiler_folder, 'new_compiler.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'B']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_compiler_folder, 'new_compiler.vim' }, sep),
|
|
|
|
[[let g:seq ..= 'a']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_compiler_folder, 'new_compiler.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'b']]
|
|
|
|
)
|
2021-06-02 00:48:13 -07:00
|
|
|
exec('compiler new_compiler')
|
2023-07-13 15:46:16 -07:00
|
|
|
eq('ABab', eval('g:seq'))
|
2021-06-02 00:48:13 -07:00
|
|
|
end)
|
|
|
|
end)
|
2021-06-02 03:25:50 -07:00
|
|
|
|
|
|
|
describe('ftplugin', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local ftplugin_folder = table.concat({ plug_dir, 'ftplugin' }, sep)
|
2021-06-02 03:25:50 -07:00
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
it('lua ftplugins work and are included in cmdline completion', function()
|
2021-06-02 03:25:50 -07:00
|
|
|
mkdir_p(ftplugin_folder)
|
2023-03-17 18:55:08 -07:00
|
|
|
local ftplugin_file = table.concat({ ftplugin_folder, 'new-ft.lua' }, sep)
|
2023-01-21 20:19:58 -07:00
|
|
|
write_file(ftplugin_file, [[vim.b.lua_ftplugin = 1]])
|
|
|
|
|
2024-01-12 10:59:57 -07:00
|
|
|
eq({ 'new-ft' }, fn.getcompletion('new-f', 'filetype'))
|
|
|
|
eq({ 'ftplugin/new-ft.lua' }, fn.getcompletion('ftplugin/new-f', 'runtime'))
|
2021-06-02 03:25:50 -07:00
|
|
|
|
|
|
|
exec [[set filetype=new-ft]]
|
2023-01-21 20:19:58 -07:00
|
|
|
eq(1, eval('b:lua_ftplugin'))
|
2021-06-02 03:25:50 -07:00
|
|
|
end)
|
2023-06-30 02:01:13 -07:00
|
|
|
|
|
|
|
it("'rtp' order is respected", function()
|
|
|
|
local after_ftplugin_folder = table.concat({ plug_dir, 'after', 'ftplugin' }, sep)
|
|
|
|
mkdir_p(table.concat({ ftplugin_folder, 'new-ft' }, sep))
|
|
|
|
mkdir_p(table.concat({ after_ftplugin_folder, 'new-ft' }, sep))
|
|
|
|
exec('set rtp+=' .. plug_dir .. '/after')
|
|
|
|
exec('let g:seq = ""')
|
|
|
|
-- A .lua file is loaded after a .vim file if they only differ in extension.
|
|
|
|
-- All files in after/ftplugin/ are loaded after all files in ftplugin/.
|
|
|
|
write_file(table.concat({ ftplugin_folder, 'new-ft.vim' }, sep), [[let g:seq ..= 'A']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ ftplugin_folder, 'new-ft.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'B']]
|
|
|
|
)
|
|
|
|
write_file(table.concat({ ftplugin_folder, 'new-ft_a.vim' }, sep), [[let g:seq ..= 'C']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ ftplugin_folder, 'new-ft_a.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'D']]
|
|
|
|
)
|
|
|
|
write_file(table.concat({ ftplugin_folder, 'new-ft', 'a.vim' }, sep), [[let g:seq ..= 'E']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ ftplugin_folder, 'new-ft', 'a.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'F']]
|
|
|
|
)
|
|
|
|
write_file(table.concat({ after_ftplugin_folder, 'new-ft.vim' }, sep), [[let g:seq ..= 'a']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_ftplugin_folder, 'new-ft.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'b']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_ftplugin_folder, 'new-ft_a.vim' }, sep),
|
|
|
|
[[let g:seq ..= 'c']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_ftplugin_folder, 'new-ft_a.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'd']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_ftplugin_folder, 'new-ft', 'a.vim' }, sep),
|
|
|
|
[[let g:seq ..= 'e']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_ftplugin_folder, 'new-ft', 'a.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'f']]
|
|
|
|
)
|
|
|
|
exec('setfiletype new-ft')
|
|
|
|
eq('ABCDEFabcdef', eval('g:seq'))
|
|
|
|
end)
|
2023-07-13 16:57:13 -07:00
|
|
|
|
|
|
|
it("'rtp' order is respected with 'fileignorecase'", function()
|
|
|
|
exec('set fileignorecase')
|
|
|
|
local after_ftplugin_folder = table.concat({ plug_dir, 'after', 'ftplugin' }, sep)
|
|
|
|
mkdir_p(table.concat({ ftplugin_folder, 'new-ft' }, sep))
|
|
|
|
mkdir_p(table.concat({ after_ftplugin_folder, 'new-ft' }, sep))
|
|
|
|
exec('set rtp+=' .. plug_dir .. '/after')
|
|
|
|
exec('let g:seq = ""')
|
|
|
|
-- A .lua file is loaded after a .vim file if they only differ in extension.
|
|
|
|
-- All files in after/ftplugin/ are loaded after all files in ftplugin/.
|
|
|
|
write_file(table.concat({ ftplugin_folder, 'new-ft.VIM' }, sep), [[let g:seq ..= 'A']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ ftplugin_folder, 'new-ft.LUA' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'B']]
|
|
|
|
)
|
|
|
|
write_file(table.concat({ ftplugin_folder, 'new-ft_a.vim' }, sep), [[let g:seq ..= 'C']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ ftplugin_folder, 'new-ft_a.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'D']]
|
|
|
|
)
|
|
|
|
write_file(table.concat({ ftplugin_folder, 'new-ft', 'a.VIM' }, sep), [[let g:seq ..= 'E']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ ftplugin_folder, 'new-ft', 'a.LUA' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'F']]
|
|
|
|
)
|
|
|
|
write_file(table.concat({ after_ftplugin_folder, 'new-ft.vim' }, sep), [[let g:seq ..= 'a']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_ftplugin_folder, 'new-ft.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'b']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_ftplugin_folder, 'new-ft_a.VIM' }, sep),
|
|
|
|
[[let g:seq ..= 'c']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_ftplugin_folder, 'new-ft_a.LUA' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'd']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_ftplugin_folder, 'new-ft', 'a.vim' }, sep),
|
|
|
|
[[let g:seq ..= 'e']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_ftplugin_folder, 'new-ft', 'a.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'f']]
|
|
|
|
)
|
|
|
|
exec('setfiletype new-ft')
|
|
|
|
eq('ABCDEFabcdef', eval('g:seq'))
|
|
|
|
end)
|
2021-06-02 03:25:50 -07:00
|
|
|
end)
|
2021-06-02 03:33:40 -07:00
|
|
|
|
|
|
|
describe('indent', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local indent_folder = table.concat({ plug_dir, 'indent' }, sep)
|
2021-06-02 03:33:40 -07:00
|
|
|
|
2023-07-13 15:46:16 -07:00
|
|
|
it('lua indents work and are included in cmdline completion', function()
|
2021-06-02 03:33:40 -07:00
|
|
|
mkdir_p(indent_folder)
|
2023-03-17 18:55:08 -07:00
|
|
|
local indent_file = table.concat({ indent_folder, 'new-ft.lua' }, sep)
|
2023-01-21 20:19:58 -07:00
|
|
|
write_file(indent_file, [[vim.b.lua_indent = 1]])
|
|
|
|
|
2024-01-12 10:59:57 -07:00
|
|
|
eq({ 'new-ft' }, fn.getcompletion('new-f', 'filetype'))
|
|
|
|
eq({ 'indent/new-ft.lua' }, fn.getcompletion('indent/new-f', 'runtime'))
|
2021-06-02 03:33:40 -07:00
|
|
|
|
|
|
|
exec [[set filetype=new-ft]]
|
2023-01-21 20:19:58 -07:00
|
|
|
eq(1, eval('b:lua_indent'))
|
2021-06-02 03:33:40 -07:00
|
|
|
end)
|
2023-07-13 15:46:16 -07:00
|
|
|
|
|
|
|
it("'rtp' order is respected", function()
|
|
|
|
local after_indent_folder = table.concat({ plug_dir, 'after', 'indent' }, sep)
|
|
|
|
mkdir_p(table.concat({ indent_folder, 'new-ft' }, sep))
|
|
|
|
mkdir_p(table.concat({ after_indent_folder, 'new-ft' }, sep))
|
|
|
|
exec('set rtp+=' .. plug_dir .. '/after')
|
|
|
|
exec('let g:seq = ""')
|
|
|
|
-- A .lua file is loaded after a .vim file if they only differ in extension.
|
|
|
|
-- All files in after/indent/ are loaded after all files in indent/.
|
|
|
|
write_file(table.concat({ indent_folder, 'new-ft.vim' }, sep), [[let g:seq ..= 'A']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ indent_folder, 'new-ft.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'B']]
|
|
|
|
)
|
|
|
|
write_file(table.concat({ after_indent_folder, 'new-ft.vim' }, sep), [[let g:seq ..= 'a']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_indent_folder, 'new-ft.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'b']]
|
|
|
|
)
|
|
|
|
exec('setfiletype new-ft')
|
|
|
|
eq('ABab', eval('g:seq'))
|
|
|
|
end)
|
2021-06-02 03:33:40 -07:00
|
|
|
end)
|
|
|
|
|
2021-06-02 08:08:28 -07:00
|
|
|
describe('syntax', function()
|
2021-06-02 09:46:25 -07:00
|
|
|
local syntax_folder = table.concat({ plug_dir, 'syntax' }, sep)
|
2021-06-02 08:08:28 -07:00
|
|
|
|
2023-01-21 20:19:58 -07:00
|
|
|
before_each(function()
|
2021-06-02 08:08:28 -07:00
|
|
|
mkdir_p(syntax_folder)
|
2023-03-17 18:55:08 -07:00
|
|
|
local syntax_file = table.concat({ syntax_folder, 'my-lang.lua' }, sep)
|
2023-01-21 20:19:58 -07:00
|
|
|
write_file(syntax_file, [[vim.b.current_syntax = 'my-lang']])
|
|
|
|
exec([[let b:current_syntax = '']])
|
|
|
|
end)
|
2021-06-02 08:08:28 -07:00
|
|
|
|
2023-01-21 20:19:58 -07:00
|
|
|
it('loads lua syntaxes on filetype change', function()
|
2021-06-02 08:08:28 -07:00
|
|
|
exec('set filetype=my-lang')
|
2023-01-21 20:19:58 -07:00
|
|
|
eq('my-lang', eval('b:current_syntax'))
|
2021-06-02 08:08:28 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('loads lua syntaxes on syntax change', function()
|
|
|
|
exec('set syntax=my-lang')
|
2023-01-21 20:19:58 -07:00
|
|
|
eq('my-lang', eval('b:current_syntax'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('loads lua syntaxes for :ownsyntax', function()
|
|
|
|
exec('ownsyntax my-lang')
|
|
|
|
eq('my-lang', eval('w:current_syntax'))
|
|
|
|
eq('', eval('b:current_syntax'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('lua syntaxes are included in cmdline completion', function()
|
2024-01-12 10:59:57 -07:00
|
|
|
eq({ 'my-lang' }, fn.getcompletion('my-l', 'filetype'))
|
|
|
|
eq({ 'my-lang' }, fn.getcompletion('my-l', 'syntax'))
|
|
|
|
eq({ 'syntax/my-lang.lua' }, fn.getcompletion('syntax/my-l', 'runtime'))
|
2021-06-02 08:08:28 -07:00
|
|
|
end)
|
2023-07-13 15:46:16 -07:00
|
|
|
|
|
|
|
it("'rtp' order is respected", function()
|
|
|
|
local after_syntax_folder = table.concat({ plug_dir, 'after', 'syntax' }, sep)
|
|
|
|
mkdir_p(table.concat({ syntax_folder, 'my-lang' }, sep))
|
|
|
|
mkdir_p(table.concat({ after_syntax_folder, 'my-lang' }, sep))
|
|
|
|
exec('set rtp+=' .. plug_dir .. '/after')
|
|
|
|
exec('let g:seq = ""')
|
|
|
|
-- A .lua file is loaded after a .vim file if they only differ in extension.
|
|
|
|
-- All files in after/syntax/ are loaded after all files in syntax/.
|
|
|
|
write_file(table.concat({ syntax_folder, 'my-lang.vim' }, sep), [[let g:seq ..= 'A']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ syntax_folder, 'my-lang.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'B']]
|
|
|
|
)
|
|
|
|
write_file(table.concat({ syntax_folder, 'my-lang', 'a.vim' }, sep), [[let g:seq ..= 'C']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ syntax_folder, 'my-lang', 'a.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'D']]
|
|
|
|
)
|
|
|
|
write_file(table.concat({ after_syntax_folder, 'my-lang.vim' }, sep), [[let g:seq ..= 'a']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_syntax_folder, 'my-lang.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'b']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_syntax_folder, 'my-lang', 'a.vim' }, sep),
|
|
|
|
[[let g:seq ..= 'c']]
|
|
|
|
)
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_syntax_folder, 'my-lang', 'a.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'd']]
|
|
|
|
)
|
|
|
|
exec('setfiletype my-lang')
|
|
|
|
eq('ABCDabcd', eval('g:seq'))
|
|
|
|
end)
|
2021-06-02 08:08:28 -07:00
|
|
|
end)
|
|
|
|
|
2023-03-17 18:55:08 -07:00
|
|
|
describe('spell', function()
|
2023-07-13 15:46:16 -07:00
|
|
|
it("loads spell/LANG.{vim,lua} respecting 'rtp' order", function()
|
|
|
|
local spell_folder = table.concat({ plug_dir, 'spell' }, sep)
|
|
|
|
local after_spell_folder = table.concat({ plug_dir, 'after', 'spell' }, sep)
|
|
|
|
mkdir_p(table.concat({ spell_folder, 'Xtest' }, sep))
|
|
|
|
mkdir_p(table.concat({ after_spell_folder, 'Xtest' }, sep))
|
|
|
|
exec('set rtp+=' .. plug_dir .. '/after')
|
|
|
|
exec('let g:seq = ""')
|
|
|
|
-- A .lua file is loaded after a .vim file if they only differ in extension.
|
|
|
|
-- All files in after/spell/ are loaded after all files in spell/.
|
|
|
|
write_file(table.concat({ spell_folder, 'Xtest.vim' }, sep), [[let g:seq ..= 'A']])
|
|
|
|
write_file(table.concat({ spell_folder, 'Xtest.lua' }, sep), [[vim.g.seq = vim.g.seq .. 'B']])
|
|
|
|
write_file(table.concat({ after_spell_folder, 'Xtest.vim' }, sep), [[let g:seq ..= 'a']])
|
|
|
|
write_file(
|
|
|
|
table.concat({ after_spell_folder, 'Xtest.lua' }, sep),
|
|
|
|
[[vim.g.seq = vim.g.seq .. 'b']]
|
|
|
|
)
|
2023-03-17 18:55:08 -07:00
|
|
|
exec('set spelllang=Xtest')
|
2023-07-13 15:46:16 -07:00
|
|
|
eq('ABab', eval('g:seq'))
|
2023-03-17 18:55:08 -07:00
|
|
|
end)
|
|
|
|
end)
|
2021-06-01 20:32:37 -07:00
|
|
|
end)
|