diff options
author | dm1try <me@dmitry.it> | 2020-05-03 23:49:11 +0300 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2020-12-01 10:51:25 +0100 |
commit | 767cd8b17b71f78bdd4c2e0dd8d3f4f0f1551381 (patch) | |
tree | 9d6d1ac306c0727e5f37c0c0cb58d665a8cf4c82 /test/functional/core | |
parent | 13b88573005d84cc0ebcd7e7bf4dd488673919d3 (diff) | |
download | rneovim-767cd8b17b71f78bdd4c2e0dd8d3f4f0f1551381.tar.gz rneovim-767cd8b17b71f78bdd4c2e0dd8d3f4f0f1551381.tar.bz2 rneovim-767cd8b17b71f78bdd4c2e0dd8d3f4f0f1551381.zip |
startup: add init.lua as an alternative user config, fixes #7895
Diffstat (limited to 'test/functional/core')
-rw-r--r-- | test/functional/core/startup_spec.lua | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 27793ab936..22880a1fe8 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -432,3 +432,64 @@ 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) |