diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-12-01 18:54:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-01 18:54:50 +0100 |
commit | 72c22862dc2199462aef0d450a49d29a9d0680b9 (patch) | |
tree | 04954cbd59abc06ac1a82511f63329290e58c11a /test/functional | |
parent | f88c2490c7971e7f8889e60316ff3767b1a3f92c (diff) | |
parent | eb387ae53009b4da93fbbb3423e5ef01023dc32a (diff) | |
download | rneovim-72c22862dc2199462aef0d450a49d29a9d0680b9.tar.gz rneovim-72c22862dc2199462aef0d450a49d29a9d0680b9.tar.bz2 rneovim-72c22862dc2199462aef0d450a49d29a9d0680b9.zip |
Merge pull request #12235 from dm1try/add_init_lua
add init.lua as an alternative user config
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/core/startup_spec.lua | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 27793ab936..ff0fdbea45 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -432,3 +432,88 @@ describe('clean', function() clear('--clean') ok(string.match(meths.get_option('runtimepath'), funcs.stdpath('config')) == nil) end) + +describe('user config init', function() + local xhome = 'Xhome' + local pathsep = helpers.get_pathsep() + local xconfig = xhome .. pathsep .. 'Xconfig' + local init_lua_path = table.concat({xconfig, 'nvim', 'init.lua'}, pathsep) + + before_each(function() + rmdir(xhome) + + -- TODO, make mkdir_p helper + mkdir(xhome) + mkdir(xconfig) + mkdir(xconfig .. pathsep .. 'nvim') + + write_file(init_lua_path, [[ + vim.g.lua_rc = 1 + ]]) + end) + + after_each(function() + rmdir(xhome) + end) + + it('loads init.lua from XDG config home by default', function() + clear{ args_rm={'-u' }, env={ XDG_CONFIG_HOME=xconfig }} + + eq(1, eval('g:lua_rc')) + eq(init_lua_path, eval('$MYVIMRC')) + end) + + describe 'with explicitly provided config'(function() + local custom_lua_path = table.concat({xhome, 'custom.lua'}, pathsep) + before_each(function() + 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={ XDG_CONFIG_HOME=xconfig }} + eq(1, eval('g:custom_lua_rc')) + eq('', eval('$MYVIMRC')) + end) + end) + + describe 'VIMRC also exists'(function() + before_each(function() + 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={ XDG_CONFIG_HOME=xconfig }} + feed('<cr>') -- TODO check this, test execution is blocked without it + eq(1, eval('g:lua_rc')) + matches('Conflicting configs', meths.exec('messages', true)) + end) + end) +end) + +describe('user session', function() + local xhome = 'Xhome' + local pathsep = helpers.get_pathsep() + local session_file = table.concat({xhome, 'session.lua'}, pathsep) + + before_each(function() + rmdir(xhome) + + mkdir(xhome) + write_file(session_file, [[ + vim.g.lua_session = 1 + ]]) + end) + + after_each(function() + rmdir(xhome) + end) + + it('loads session from the provided lua file', function() + clear{ args={'-S', session_file }, env={ HOME=xhome }} + eq(1, eval('g:lua_session')) + end) +end) |