diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-09-11 20:11:16 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2021-09-18 13:59:19 +0200 |
commit | a860f7880fd5d5cef5299ff8d450ac037bee2300 (patch) | |
tree | b929329658316d6a8a7aead01f0b701c0e278fca /test/functional/core/startup_spec.lua | |
parent | 396280d3030685c6b7c4d962f24bb5171a735b47 (diff) | |
download | rneovim-a860f7880fd5d5cef5299ff8d450ac037bee2300.tar.gz rneovim-a860f7880fd5d5cef5299ff8d450ac037bee2300.tar.bz2 rneovim-a860f7880fd5d5cef5299ff8d450ac037bee2300.zip |
refactor(runtime): handle pack/foo/start/bar/after dirs properly
The order should be:
XDG_CONFIG_HOME/nvim
XDG_DATA_HOME/nvim/site/pack/foo/start/bar/
XDG_CONFIG_HOME/nvim/after
XDG_DATA_HOME/nvim/site/pack/foo/start/bar/after
Diffstat (limited to 'test/functional/core/startup_spec.lua')
-rw-r--r-- | test/functional/core/startup_spec.lua | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 861889e7fc..f057420dde 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -310,7 +310,7 @@ describe('startup', function() end) local function pack_clear(cmd) - clear('--cmd', 'set packpath=test/functional/fixtures', '--cmd', cmd) + clear{args={'--cmd', 'set packpath=test/functional/fixtures', '--cmd', cmd}, env={XDG_CONFIG_HOME='test/functional/fixtures/'}} end @@ -348,6 +348,16 @@ describe('startup', function() pack_clear [[ packadd! bonus | lua _G.y = require'bonus'.launch() ]] eq('CPE 1704 TKS', exec_lua [[ return _G.y ]]) end) + + 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', 'ordinary after', 'FANCY after'}, exec_lua [[ return _G.test_loadorder ]]) + end) + + 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', 'SuperSpecial after', 'ordinary after', 'FANCY after'}, exec_lua [[ return _G.test_loadorder ]]) + end) end) describe('sysinit', function() @@ -504,6 +514,7 @@ describe('runtime:', function() local xenv = { XDG_CONFIG_HOME=xconfig, XDG_DATA_HOME=xdata } setup(function() + rmdir(xhome) mkdir_p(xconfig .. pathsep .. 'nvim') mkdir_p(xdata) end) @@ -524,7 +535,7 @@ describe('runtime:', function() rmdir(plugin_folder_path) end) - it('loads plugin/*.lua from start plugins', function() + it('loads plugin/*.lua from start packages', function() local plugin_path = table.concat({xconfig, 'nvim', 'pack', 'catagory', 'start', 'test_plugin'}, pathsep) local plugin_folder_path = table.concat({plugin_path, 'plugin'}, pathsep) @@ -552,6 +563,27 @@ describe('runtime:', function() rmdir(plugin_path) end) + it('loads plugin/*.lua from site packages', function() + local nvimdata = iswin() 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) + write_file(plugin_file_path, [[table.insert(_G.lista, "unos")]]) + mkdir_p(plugin_after_path) + write_file(plugin_after_file_path, [[table.insert(_G.lista, "dos")]]) + + clear{ args_rm={'-u'}, args={'--cmd', 'lua _G.lista = {}'}, env=xenv } + + eq({'unos', 'dos'}, exec_lua "return _G.lista") + + rmdir(plugin_path) + end) + + it('loads ftdetect/*.lua', function() local ftdetect_folder = table.concat({xconfig, 'nvim', 'ftdetect'}, pathsep) local ftdetect_file = table.concat({ftdetect_folder , 'new-ft.lua'}, pathsep) |