aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshadmansaleh <shadmansaleh3@gmail.com>2021-05-31 17:35:13 +0600
committershadmansaleh <shadmansaleh3@gmail.com>2021-06-11 00:58:38 +0600
commit687eb0b39f3bcad9566198b4c60bbd2755032991 (patch)
treed118e6d1adc4e9fdff845912e1606ab40ae8b454 /test
parent1df8a34a7b91028413d6ac751b9dbf9fdcd6cda2 (diff)
downloadrneovim-687eb0b39f3bcad9566198b4c60bbd2755032991.tar.gz
rneovim-687eb0b39f3bcad9566198b4c60bbd2755032991.tar.bz2
rneovim-687eb0b39f3bcad9566198b4c60bbd2755032991.zip
feat(startup): Source runtime/plugin/**/*.lua at startup
For opt plugins these files are sourced on `:packadd` * `:runtime` Now can exexute lua files
Diffstat (limited to 'test')
-rw-r--r--test/functional/core/startup_spec.lua48
-rw-r--r--test/functional/helpers.lua5
-rw-r--r--test/functional/legacy/packadd_spec.lua10
3 files changed, 63 insertions, 0 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index d5f03db03a..258fea85e4 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -11,6 +11,7 @@ local exec_lua = helpers.exec_lua
local feed = helpers.feed
local funcs = helpers.funcs
local mkdir = helpers.mkdir
+local mkdir_p = helpers.mkdir_p
local nvim_prog = helpers.nvim_prog
local nvim_set = helpers.nvim_set
local read_file = helpers.read_file
@@ -494,6 +495,53 @@ describe('user config init', function()
end)
end)
+describe('runtime/plugin', function()
+ local xhome = 'Xhome'
+ local pathsep = helpers.get_pathsep()
+ local xconfig = xhome .. pathsep .. 'Xconfig'
+
+ before_each(function()
+ mkdir_p(xconfig .. pathsep .. 'nvim')
+ end)
+
+ after_each(function()
+ rmdir(xhome)
+ 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)
+ mkdir_p(plugin_folder_path)
+ write_file(plugin_file_path, [[
+ vim.g.lua_plugin = 1
+ ]])
+
+ clear{ args_rm={'-u' }, env={ XDG_CONFIG_HOME=xconfig }}
+
+ eq(1, eval('g:lua_plugin'))
+ rmdir(plugin_folder_path)
+ end)
+
+
+ it('loads plugin/*.lua from start plugins', function()
+ local plugin_path = table.concat({xconfig, 'nvim', 'pack', 'catagory',
+ '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)
+ mkdir_p(plugin_folder_path)
+ write_file(plugin_file_path, [[
+ vim.g.lua_plugin = 2
+ ]])
+
+ clear{ args_rm={'-u' }, env={ XDG_CONFIG_HOME=xconfig }}
+
+ eq(2, eval('g:lua_plugin'))
+ rmdir(plugin_path)
+ end)
+
+end)
+
describe('user session', function()
local xhome = 'Xhome'
local pathsep = helpers.get_pathsep()
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 4acb1a7d8d..08ca14c3df 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -878,6 +878,11 @@ function module.os_kill(pid)
or 'kill -9 '..pid..' > /dev/null'))
end
+-- Create directories with non exsisting intermidiate directories
+function module.mkdir_p(path)
+ return module.meths.call_function('mkdir', {path, 'p'})
+end
+
module = global_helpers.tbl_extend('error', module, global_helpers)
return function(after_each)
diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua
index 486a1fe471..48cd3ef9f8 100644
--- a/test/functional/legacy/packadd_spec.lua
+++ b/test/functional/legacy/packadd_spec.lua
@@ -101,9 +101,14 @@ describe('packadd', function()
call setline(1, 'let g:plugin_works = 24')
wq
+ exe 'split ' . plugdir . '/plugin/test.lua'
+ call setline(1, 'vim.g.plugin_lua_works = 24')
+ wq
+
packadd other
call assert_equal(24, g:plugin_works)
+ call assert_equal(24, g:plugin_lua_works)
call assert_true(len(&rtp) > len(rtp))
call assert_match(Escape(plugdir) . '\($\|,\)', &rtp)
endfunc
@@ -117,13 +122,18 @@ describe('packadd', function()
exe 'split ' . s:plugdir . '/plugin/test.vim'
call setline(1, 'let g:plugin_works = 42')
wq
+ exe 'split ' . s:plugdir . '/plugin/test.lua'
+ call setline(1, 'let g:plugin_lua_works = 42')
+ wq
let g:plugin_works = 0
+ let g:plugin_lua_works = 0
packadd! mytest
call assert_true(len(&rtp) > len(rtp))
call assert_match(Escape(s:plugdir) . '\($\|,\)', &rtp)
call assert_equal(0, g:plugin_works)
+ call assert_equal(0, g:plugin_lua_works)
" check the path is not added twice
let new_rtp = &rtp