diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2024-01-03 02:09:18 +0100 |
|---|---|---|
| committer | Justin M. Keyes <justinkz@gmail.com> | 2024-01-03 02:09:29 +0100 |
| commit | 04f2f864e270e772c6326cefdf24947f0130e492 (patch) | |
| tree | 46f83f909b888a66c741032ab955afc6eab84292 /test/functional/options/defaults_spec.lua | |
| parent | 59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff) | |
| download | rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2 rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip | |
refactor: format test/*
Diffstat (limited to 'test/functional/options/defaults_spec.lua')
| -rw-r--r-- | test/functional/options/defaults_spec.lua | 1072 |
1 files changed, 689 insertions, 383 deletions
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index 4a0aa7d023..1d5f657542 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -33,49 +33,38 @@ describe('startup defaults', function() screen:expect([[ ^ | ~ |*2 - ]]..expected - ) + ]] .. expected) end it('all ON after `-u NORC`', function() clear('-u', 'NORC') - expect_filetype( - 'filetype detection:ON plugin:ON indent:ON |') + expect_filetype('filetype detection:ON plugin:ON indent:ON |') end) it('all ON after `:syntax …` #7765', function() clear('-u', 'NORC', '--cmd', 'syntax on') - expect_filetype( - 'filetype detection:ON plugin:ON indent:ON |') + expect_filetype('filetype detection:ON plugin:ON indent:ON |') clear('-u', 'NORC', '--cmd', 'syntax off') - expect_filetype( - 'filetype detection:ON plugin:ON indent:ON |') + expect_filetype('filetype detection:ON plugin:ON indent:ON |') end) it('all OFF after `-u NONE`', function() clear('-u', 'NONE') - expect_filetype( - 'filetype detection:OFF plugin:OFF indent:OFF |') + expect_filetype('filetype detection:OFF plugin:OFF indent:OFF |') end) it('explicit OFF stays OFF', function() - clear('-u', 'NORC', '--cmd', - 'syntax off | filetype off | filetype plugin indent off') - expect_filetype( - 'filetype detection:OFF plugin:OFF indent:OFF |') + clear('-u', 'NORC', '--cmd', 'syntax off | filetype off | filetype plugin indent off') + expect_filetype('filetype detection:OFF plugin:OFF indent:OFF |') clear('-u', 'NORC', '--cmd', 'syntax off | filetype plugin indent off') - expect_filetype( - 'filetype detection:ON plugin:OFF indent:OFF |') + expect_filetype('filetype detection:ON plugin:OFF indent:OFF |') clear('-u', 'NORC', '--cmd', 'filetype indent off') - expect_filetype( - 'filetype detection:ON plugin:ON indent:OFF |') + expect_filetype('filetype detection:ON plugin:ON indent:OFF |') clear('-u', 'NORC', '--cmd', 'syntax off | filetype off') - expect_filetype( - 'filetype detection:OFF plugin:(on) indent:(on) |') + expect_filetype('filetype detection:OFF plugin:(on) indent:(on) |') -- Swap the order. clear('-u', 'NORC', '--cmd', 'filetype off | syntax off') - expect_filetype( - 'filetype detection:OFF plugin:(on) indent:(on) |') + expect_filetype('filetype detection:OFF plugin:(on) indent:(on) |') end) it('all ON after early `:filetype … on`', function() @@ -83,26 +72,20 @@ describe('startup defaults', function() -- Only an explicit `:filetype … off` sets OFF. clear('-u', 'NORC', '--cmd', 'filetype on') - expect_filetype( - 'filetype detection:ON plugin:ON indent:ON |') + expect_filetype('filetype detection:ON plugin:ON indent:ON |') clear('-u', 'NORC', '--cmd', 'filetype plugin on') - expect_filetype( - 'filetype detection:ON plugin:ON indent:ON |') + expect_filetype('filetype detection:ON plugin:ON indent:ON |') clear('-u', 'NORC', '--cmd', 'filetype indent on') - expect_filetype( - 'filetype detection:ON plugin:ON indent:ON |') + expect_filetype('filetype detection:ON plugin:ON indent:ON |') end) it('late `:filetype … off` stays OFF', function() clear('-u', 'NORC', '-c', 'filetype off') - expect_filetype( - 'filetype detection:OFF plugin:(on) indent:(on) |') + expect_filetype('filetype detection:OFF plugin:(on) indent:(on) |') clear('-u', 'NORC', '-c', 'filetype plugin off') - expect_filetype( - 'filetype detection:ON plugin:OFF indent:ON |') + expect_filetype('filetype detection:ON plugin:OFF indent:ON |') clear('-u', 'NORC', '-c', 'filetype indent off') - expect_filetype( - 'filetype detection:ON plugin:ON indent:OFF |') + expect_filetype('filetype detection:ON plugin:ON indent:OFF |') end) end) @@ -166,7 +149,7 @@ describe('startup defaults', function() ]]) -- change "vert" character to single-cell - funcs.setcellwidths({{0x2502, 0x2502, 1}}) + funcs.setcellwidths({ { 0x2502, 0x2502, 1 } }) screen:expect([[ 1 │1 | ^+-- 2 lines: 2----------│+-- 2 lines: 2---------| @@ -176,7 +159,7 @@ describe('startup defaults', function() ]]) -- change "vert" character to double-cell - funcs.setcellwidths({{0x2502, 0x2502, 2}}) + funcs.setcellwidths({ { 0x2502, 0x2502, 2 } }) screen:expect([[ 1 |1 | ^+-- 2 lines: 2----------|+-- 2 lines: 2---------| @@ -198,14 +181,18 @@ describe('startup defaults', function() end) it("'shadafile' ('viminfofile')", function() - local env = {XDG_DATA_HOME='Xtest-userdata', XDG_STATE_HOME='Xtest-userstate', XDG_CONFIG_HOME='Xtest-userconfig'} + local env = { + XDG_DATA_HOME = 'Xtest-userdata', + XDG_STATE_HOME = 'Xtest-userstate', + XDG_CONFIG_HOME = 'Xtest-userconfig', + } finally(function() - command('set shadafile=NONE') -- Avoid writing shada file on exit + command('set shadafile=NONE') -- Avoid writing shada file on exit rmdir('Xtest-userstate') os.remove('Xtest-foo') end) - clear{args={}, args_rm={'-i'}, env=env} + clear { args = {}, args_rm = { '-i' }, env = env } -- Default 'shadafile' is empty. -- This means use the default location. :help shada-file-name eq('', meths.get_option_value('shadafile', {})) @@ -222,13 +209,13 @@ describe('startup defaults', function() local f = eval('fnamemodify(@%,":p")') assert(string.len(f) > 3) expect_exit(command, 'qall') - clear{args={}, args_rm={'-i'}, env=env} + clear { args = {}, args_rm = { '-i' }, env = env } eq({ f }, eval('v:oldfiles')) end) it("'packpath'", function() - clear{ - args_rm={'runtimepath'}, + clear { + args_rm = { 'runtimepath' }, } -- Defaults to &runtimepath. eq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {})) @@ -247,33 +234,37 @@ describe('startup defaults', function() describe('$NVIM_LOG_FILE', function() local xdgdir = 'Xtest-startup-xdg-logpath' - local xdgstatedir = is_os('win') and xdgdir..'/nvim-data' or xdgdir..'/nvim' + local xdgstatedir = is_os('win') and xdgdir .. '/nvim-data' or xdgdir .. '/nvim' after_each(function() os.remove('Xtest-logpath') rmdir(xdgdir) end) it('is used if expansion succeeds', function() - clear({env={ - NVIM_LOG_FILE='Xtest-logpath', - }}) + clear({ env = { + NVIM_LOG_FILE = 'Xtest-logpath', + } }) eq('Xtest-logpath', eval('$NVIM_LOG_FILE')) end) it('defaults to stdpath("log")/log if empty', function() eq(true, mkdir(xdgdir) and mkdir(xdgstatedir)) - clear({env={ - XDG_STATE_HOME=xdgdir, - NVIM_LOG_FILE='', -- Empty is invalid. - }}) - eq(xdgstatedir..'/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/')) + clear({ + env = { + XDG_STATE_HOME = xdgdir, + NVIM_LOG_FILE = '', -- Empty is invalid. + }, + }) + eq(xdgstatedir .. '/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/')) end) it('defaults to stdpath("log")/log if invalid', function() eq(true, mkdir(xdgdir) and mkdir(xdgstatedir)) - clear({env={ - XDG_STATE_HOME=xdgdir, - NVIM_LOG_FILE='.', -- Any directory is invalid. - }}) - eq(xdgstatedir..'/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/')) + clear({ + env = { + XDG_STATE_HOME = xdgdir, + NVIM_LOG_FILE = '.', -- Any directory is invalid. + }, + }) + eq(xdgstatedir .. '/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/')) end) end) end) @@ -290,11 +281,12 @@ describe('XDG defaults', function() clear() local rtp = eval('split(&runtimepath, ",")') local rv = {} - local expected = (is_os('win') - and { [[\nvim-data\site]], [[\nvim-data\site\after]], } - or { '/nvim/site', '/nvim/site/after', }) + local expected = ( + is_os('win') and { [[\nvim-data\site]], [[\nvim-data\site\after]] } + or { '/nvim/site', '/nvim/site/after' } + ) - for _,v in ipairs(rtp) do + for _, v in ipairs(rtp) do local m = string.match(v, [=[[/\]nvim[^/\]*[/\]site.*$]=]) if m and not tbl_contains(rv, m) then table.insert(rv, m) @@ -305,22 +297,24 @@ describe('XDG defaults', function() describe('with empty/broken environment', function() it('sets correct defaults', function() - clear({env={ - XDG_CONFIG_HOME=nil, - XDG_DATA_HOME=nil, - XDG_CACHE_HOME=nil, - XDG_STATE_HOME=nil, - XDG_RUNTIME_DIR=nil, - XDG_CONFIG_DIRS=nil, - XDG_DATA_DIRS=nil, - LOCALAPPDATA=nil, - HOMEPATH=nil, - HOMEDRIVE=nil, - HOME=nil, - TEMP=nil, - VIMRUNTIME=nil, - USER=nil, - }}) + clear({ + env = { + XDG_CONFIG_HOME = nil, + XDG_DATA_HOME = nil, + XDG_CACHE_HOME = nil, + XDG_STATE_HOME = nil, + XDG_RUNTIME_DIR = nil, + XDG_CONFIG_DIRS = nil, + XDG_DATA_DIRS = nil, + LOCALAPPDATA = nil, + HOMEPATH = nil, + HOMEDRIVE = nil, + HOME = nil, + TEMP = nil, + VIMRUNTIME = nil, + USER = nil, + }, + }) eq('.', meths.get_option_value('backupdir', {})) eq('.', meths.get_option_value('viewdir', {})) @@ -346,20 +340,21 @@ describe('XDG defaults', function() describe('with too long XDG variables', function() before_each(function() clear({ - args_rm={'runtimepath'}, - env={ - NVIM_LOG_FILE=testlog, - XDG_CONFIG_HOME=(root_path .. ('/x'):rep(4096)), - XDG_CONFIG_DIRS=(root_path .. ('/a'):rep(2048) - .. env_sep.. root_path .. ('/b'):rep(2048) - .. (env_sep .. root_path .. '/c'):rep(512)), - XDG_DATA_HOME=(root_path .. ('/X'):rep(4096)), - XDG_RUNTIME_DIR=(root_path .. ('/X'):rep(4096)), - XDG_STATE_HOME=(root_path .. ('/X'):rep(4096)), - XDG_DATA_DIRS=(root_path .. ('/A'):rep(2048) - .. env_sep .. root_path .. ('/B'):rep(2048) - .. (env_sep .. root_path .. '/C'):rep(512)), - }}) + args_rm = { 'runtimepath' }, + env = { + NVIM_LOG_FILE = testlog, + XDG_CONFIG_HOME = (root_path .. ('/x'):rep(4096)), + XDG_CONFIG_DIRS = (root_path .. ('/a'):rep(2048) .. env_sep .. root_path .. ('/b'):rep( + 2048 + ) .. (env_sep .. root_path .. '/c'):rep(512)), + XDG_DATA_HOME = (root_path .. ('/X'):rep(4096)), + XDG_RUNTIME_DIR = (root_path .. ('/X'):rep(4096)), + XDG_STATE_HOME = (root_path .. ('/X'):rep(4096)), + XDG_DATA_DIRS = (root_path .. ('/A'):rep(2048) .. env_sep .. root_path .. ('/B'):rep( + 2048 + ) .. (env_sep .. root_path .. '/C'):rep(512)), + }, + }) end) it('are correctly set', function() @@ -369,141 +364,297 @@ describe('XDG defaults', function() local vimruntime, libdir = vimruntime_and_libdir() - eq(((root_path .. ('/x'):rep(4096) .. '/nvim' - .. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim' - .. ',' .. root_path .. ('/b'):rep(2048) .. '/nvim' - .. (',' .. root_path .. '/c/nvim'):rep(512) - .. ',' .. root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/site' - .. ',' .. root_path .. ('/A'):rep(2048) .. '/nvim/site' - .. ',' .. root_path .. ('/B'):rep(2048) .. '/nvim/site' - .. (',' .. root_path .. '/C/nvim/site'):rep(512) - .. ',' .. vimruntime - .. ',' .. libdir - .. (',' .. root_path .. '/C/nvim/site/after'):rep(512) - .. ',' .. root_path .. ('/B'):rep(2048) .. '/nvim/site/after' - .. ',' .. root_path .. ('/A'):rep(2048) .. '/nvim/site/after' - .. ',' .. root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/site/after' - .. (',' .. root_path .. '/c/nvim/after'):rep(512) - .. ',' .. root_path .. ('/b'):rep(2048) .. '/nvim/after' - .. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim/after' - .. ',' .. root_path .. ('/x'):rep(4096) .. '/nvim/after' - ):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/')) + eq( + ( + ( + root_path + .. ('/x'):rep(4096) + .. '/nvim' + .. ',' + .. root_path + .. ('/a'):rep(2048) + .. '/nvim' + .. ',' + .. root_path + .. ('/b'):rep(2048) + .. '/nvim' + .. (',' .. root_path .. '/c/nvim'):rep(512) + .. ',' + .. root_path + .. ('/X'):rep(4096) + .. '/' + .. data_dir + .. '/site' + .. ',' + .. root_path + .. ('/A'):rep(2048) + .. '/nvim/site' + .. ',' + .. root_path + .. ('/B'):rep(2048) + .. '/nvim/site' + .. (',' .. root_path .. '/C/nvim/site'):rep(512) + .. ',' + .. vimruntime + .. ',' + .. libdir + .. (',' .. root_path .. '/C/nvim/site/after'):rep(512) + .. ',' + .. root_path + .. ('/B'):rep(2048) + .. '/nvim/site/after' + .. ',' + .. root_path + .. ('/A'):rep(2048) + .. '/nvim/site/after' + .. ',' + .. root_path + .. ('/X'):rep(4096) + .. '/' + .. data_dir + .. '/site/after' + .. (',' .. root_path .. '/c/nvim/after'):rep(512) + .. ',' + .. root_path + .. ('/b'):rep(2048) + .. '/nvim/after' + .. ',' + .. root_path + .. ('/a'):rep(2048) + .. '/nvim/after' + .. ',' + .. root_path + .. ('/x'):rep(4096) + .. '/nvim/after' + ):gsub('\\', '/') + ), + (meths.get_option_value('runtimepath', {})):gsub('\\', '/') + ) meths.command('set runtimepath&') meths.command('set backupdir&') meths.command('set directory&') meths.command('set undodir&') meths.command('set viewdir&') - eq(((root_path .. ('/x'):rep(4096) .. '/nvim' - .. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim' - .. ',' .. root_path .. ('/b'):rep(2048) .. '/nvim' - .. (',' .. root_path .. '/c/nvim'):rep(512) - .. ',' .. root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/site' - .. ',' .. root_path .. ('/A'):rep(2048) .. '/nvim/site' - .. ',' .. root_path .. ('/B'):rep(2048) .. '/nvim/site' - .. (',' .. root_path .. '/C/nvim/site'):rep(512) - .. ',' .. vimruntime - .. ',' .. libdir - .. (',' .. root_path .. '/C/nvim/site/after'):rep(512) - .. ',' .. root_path .. ('/B'):rep(2048) .. '/nvim/site/after' - .. ',' .. root_path .. ('/A'):rep(2048) .. '/nvim/site/after' - .. ',' .. root_path .. ('/X'):rep(4096) .. '/' .. data_dir .. '/site/after' - .. (',' .. root_path .. '/c/nvim/after'):rep(512) - .. ',' .. root_path .. ('/b'):rep(2048) .. '/nvim/after' - .. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim/after' - .. ',' .. root_path .. ('/x'):rep(4096) .. '/nvim/after' - ):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/')) - eq('.,' .. root_path .. ('/X'):rep(4096).. '/' .. state_dir .. '/backup//', - (meths.get_option_value('backupdir', {}):gsub('\\', '/'))) - eq(root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/swap//', - (meths.get_option_value('directory', {})):gsub('\\', '/')) - eq(root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/undo//', - (meths.get_option_value('undodir', {})):gsub('\\', '/')) - eq(root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/view//', - (meths.get_option_value('viewdir', {})):gsub('\\', '/')) + eq( + ( + ( + root_path + .. ('/x'):rep(4096) + .. '/nvim' + .. ',' + .. root_path + .. ('/a'):rep(2048) + .. '/nvim' + .. ',' + .. root_path + .. ('/b'):rep(2048) + .. '/nvim' + .. (',' .. root_path .. '/c/nvim'):rep(512) + .. ',' + .. root_path + .. ('/X'):rep(4096) + .. '/' + .. data_dir + .. '/site' + .. ',' + .. root_path + .. ('/A'):rep(2048) + .. '/nvim/site' + .. ',' + .. root_path + .. ('/B'):rep(2048) + .. '/nvim/site' + .. (',' .. root_path .. '/C/nvim/site'):rep(512) + .. ',' + .. vimruntime + .. ',' + .. libdir + .. (',' .. root_path .. '/C/nvim/site/after'):rep(512) + .. ',' + .. root_path + .. ('/B'):rep(2048) + .. '/nvim/site/after' + .. ',' + .. root_path + .. ('/A'):rep(2048) + .. '/nvim/site/after' + .. ',' + .. root_path + .. ('/X'):rep(4096) + .. '/' + .. data_dir + .. '/site/after' + .. (',' .. root_path .. '/c/nvim/after'):rep(512) + .. ',' + .. root_path + .. ('/b'):rep(2048) + .. '/nvim/after' + .. ',' + .. root_path + .. ('/a'):rep(2048) + .. '/nvim/after' + .. ',' + .. root_path + .. ('/x'):rep(4096) + .. '/nvim/after' + ):gsub('\\', '/') + ), + (meths.get_option_value('runtimepath', {})):gsub('\\', '/') + ) + eq( + '.,' .. root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/backup//', + (meths.get_option_value('backupdir', {}):gsub('\\', '/')) + ) + eq( + root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/swap//', + (meths.get_option_value('directory', {})):gsub('\\', '/') + ) + eq( + root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/undo//', + (meths.get_option_value('undodir', {})):gsub('\\', '/') + ) + eq( + root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/view//', + (meths.get_option_value('viewdir', {})):gsub('\\', '/') + ) end) end) describe('with XDG variables that can be expanded', function() before_each(function() clear({ - args_rm={'runtimepath'}, - env={ - NVIM_LOG_FILE=testlog, - XDG_CONFIG_HOME='$XDG_DATA_HOME', - XDG_CONFIG_DIRS='$XDG_DATA_DIRS', - XDG_DATA_HOME='$XDG_CONFIG_HOME', - XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR', - XDG_STATE_HOME='$XDG_CONFIG_HOME', - XDG_DATA_DIRS='$XDG_CONFIG_DIRS', - } + args_rm = { 'runtimepath' }, + env = { + NVIM_LOG_FILE = testlog, + XDG_CONFIG_HOME = '$XDG_DATA_HOME', + XDG_CONFIG_DIRS = '$XDG_DATA_DIRS', + XDG_DATA_HOME = '$XDG_CONFIG_HOME', + XDG_RUNTIME_DIR = '$XDG_RUNTIME_DIR', + XDG_STATE_HOME = '$XDG_CONFIG_HOME', + XDG_DATA_DIRS = '$XDG_CONFIG_DIRS', + }, }) end) after_each(function() - command('set shadafile=NONE') -- Avoid writing shada file on exit + command('set shadafile=NONE') -- Avoid writing shada file on exit end) it('are not expanded', function() if not is_os('win') then - assert_log('Failed to start server: no such file or directory: %$XDG_RUNTIME_DIR%/', testlog, 10) + assert_log( + 'Failed to start server: no such file or directory: %$XDG_RUNTIME_DIR%/', + testlog, + 10 + ) end local vimruntime, libdir = vimruntime_and_libdir() - eq((('$XDG_DATA_HOME/nvim' - .. ',$XDG_DATA_DIRS/nvim' - .. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site' - .. ',$XDG_CONFIG_DIRS/nvim/site' - .. ',' .. vimruntime - .. ',' .. libdir - .. ',$XDG_CONFIG_DIRS/nvim/site/after' - .. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after' - .. ',$XDG_DATA_DIRS/nvim/after' - .. ',$XDG_DATA_HOME/nvim/after' - ):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/')) + eq( + ( + ( + '$XDG_DATA_HOME/nvim' + .. ',$XDG_DATA_DIRS/nvim' + .. ',$XDG_CONFIG_HOME/' + .. data_dir + .. '/site' + .. ',$XDG_CONFIG_DIRS/nvim/site' + .. ',' + .. vimruntime + .. ',' + .. libdir + .. ',$XDG_CONFIG_DIRS/nvim/site/after' + .. ',$XDG_CONFIG_HOME/' + .. data_dir + .. '/site/after' + .. ',$XDG_DATA_DIRS/nvim/after' + .. ',$XDG_DATA_HOME/nvim/after' + ):gsub('\\', '/') + ), + (meths.get_option_value('runtimepath', {})):gsub('\\', '/') + ) meths.command('set runtimepath&') meths.command('set backupdir&') meths.command('set directory&') meths.command('set undodir&') meths.command('set viewdir&') - eq((('$XDG_DATA_HOME/nvim' - .. ',$XDG_DATA_DIRS/nvim' - .. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site' - .. ',$XDG_CONFIG_DIRS/nvim/site' - .. ',' .. vimruntime - .. ',' .. libdir - .. ',$XDG_CONFIG_DIRS/nvim/site/after' - .. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after' - .. ',$XDG_DATA_DIRS/nvim/after' - .. ',$XDG_DATA_HOME/nvim/after' - ):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/')) - eq(('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'), - meths.get_option_value('backupdir', {}):gsub('\\', '/')) - eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'), - meths.get_option_value('directory', {}):gsub('\\', '/')) - eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'), - meths.get_option_value('undodir', {}):gsub('\\', '/')) - eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'), - meths.get_option_value('viewdir', {}):gsub('\\', '/')) + eq( + ( + ( + '$XDG_DATA_HOME/nvim' + .. ',$XDG_DATA_DIRS/nvim' + .. ',$XDG_CONFIG_HOME/' + .. data_dir + .. '/site' + .. ',$XDG_CONFIG_DIRS/nvim/site' + .. ',' + .. vimruntime + .. ',' + .. libdir + .. ',$XDG_CONFIG_DIRS/nvim/site/after' + .. ',$XDG_CONFIG_HOME/' + .. data_dir + .. '/site/after' + .. ',$XDG_DATA_DIRS/nvim/after' + .. ',$XDG_DATA_HOME/nvim/after' + ):gsub('\\', '/') + ), + (meths.get_option_value('runtimepath', {})):gsub('\\', '/') + ) + eq( + ('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'), + meths.get_option_value('backupdir', {}):gsub('\\', '/') + ) + eq( + ('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'), + meths.get_option_value('directory', {}):gsub('\\', '/') + ) + eq( + ('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'), + meths.get_option_value('undodir', {}):gsub('\\', '/') + ) + eq( + ('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'), + meths.get_option_value('viewdir', {}):gsub('\\', '/') + ) meths.command('set all&') - eq(('$XDG_DATA_HOME/nvim' + eq( + ( + '$XDG_DATA_HOME/nvim' .. ',$XDG_DATA_DIRS/nvim' - .. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site' + .. ',$XDG_CONFIG_HOME/' + .. data_dir + .. '/site' .. ',$XDG_CONFIG_DIRS/nvim/site' - .. ',' .. vimruntime - .. ',' .. libdir + .. ',' + .. vimruntime + .. ',' + .. libdir .. ',$XDG_CONFIG_DIRS/nvim/site/after' - .. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after' + .. ',$XDG_CONFIG_HOME/' + .. data_dir + .. '/site/after' .. ',$XDG_DATA_DIRS/nvim/after' .. ',$XDG_DATA_HOME/nvim/after' - ):gsub('\\', '/'), (meths.get_option_value('runtimepath', {})):gsub('\\', '/')) - eq(('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'), - meths.get_option_value('backupdir', {}):gsub('\\', '/')) - eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'), - meths.get_option_value('directory', {}):gsub('\\', '/')) - eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'), - meths.get_option_value('undodir', {}):gsub('\\', '/')) - eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'), - meths.get_option_value('viewdir', {}):gsub('\\', '/')) + ):gsub('\\', '/'), + (meths.get_option_value('runtimepath', {})):gsub('\\', '/') + ) + eq( + ('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'), + meths.get_option_value('backupdir', {}):gsub('\\', '/') + ) + eq( + ('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'), + meths.get_option_value('directory', {}):gsub('\\', '/') + ) + eq( + ('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'), + meths.get_option_value('undodir', {}):gsub('\\', '/') + ) + eq( + ('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'), + meths.get_option_value('viewdir', {}):gsub('\\', '/') + ) eq(nil, (funcs.tempname()):match('XDG_RUNTIME_DIR')) end) end) @@ -511,67 +662,208 @@ describe('XDG defaults', function() describe('with commas', function() before_each(function() clear({ - args_rm={'runtimepath'}, - env={ - XDG_CONFIG_HOME=', , ,', - XDG_CONFIG_DIRS=',-,-,' .. env_sep .. '-,-,-', - XDG_DATA_HOME=',=,=,', - XDG_STATE_HOME=',=,=,', - XDG_DATA_DIRS=',≡,≡,' .. env_sep .. '≡,≡,≡', - }}) + args_rm = { 'runtimepath' }, + env = { + XDG_CONFIG_HOME = ', , ,', + XDG_CONFIG_DIRS = ',-,-,' .. env_sep .. '-,-,-', + XDG_DATA_HOME = ',=,=,', + XDG_STATE_HOME = ',=,=,', + XDG_DATA_DIRS = ',≡,≡,' .. env_sep .. '≡,≡,≡', + }, + }) end) it('are escaped properly', function() local vimruntime, libdir = vimruntime_and_libdir() local path_sep = is_os('win') and '\\' or '/' - eq(('\\, \\, \\,' .. path_sep .. 'nvim' - .. ',\\,-\\,-\\,' .. path_sep .. 'nvim' - .. ',-\\,-\\,-' .. path_sep .. 'nvim' - .. ',\\,=\\,=\\,' .. path_sep .. data_dir .. path_sep .. 'site' - .. ',\\,≡\\,≡\\,' .. path_sep .. 'nvim' .. path_sep .. 'site' - .. ',≡\\,≡\\,≡' .. path_sep .. 'nvim' .. path_sep .. 'site' - .. ',' .. vimruntime - .. ',' .. libdir - .. ',≡\\,≡\\,≡' .. path_sep .. 'nvim' .. path_sep .. 'site' .. path_sep .. 'after' - .. ',\\,≡\\,≡\\,' .. path_sep .. 'nvim' .. path_sep .. 'site' .. path_sep .. 'after' - .. ',\\,=\\,=\\,' .. path_sep.. data_dir .. path_sep .. 'site' .. path_sep .. 'after' - .. ',-\\,-\\,-' .. path_sep .. 'nvim' .. path_sep .. 'after' - .. ',\\,-\\,-\\,' .. path_sep .. 'nvim' .. path_sep .. 'after' - .. ',\\, \\, \\,' .. path_sep .. 'nvim' .. path_sep .. 'after' - ), meths.get_option_value('runtimepath', {})) + eq( + ( + '\\, \\, \\,' + .. path_sep + .. 'nvim' + .. ',\\,-\\,-\\,' + .. path_sep + .. 'nvim' + .. ',-\\,-\\,-' + .. path_sep + .. 'nvim' + .. ',\\,=\\,=\\,' + .. path_sep + .. data_dir + .. path_sep + .. 'site' + .. ',\\,≡\\,≡\\,' + .. path_sep + .. 'nvim' + .. path_sep + .. 'site' + .. ',≡\\,≡\\,≡' + .. path_sep + .. 'nvim' + .. path_sep + .. 'site' + .. ',' + .. vimruntime + .. ',' + .. libdir + .. ',≡\\,≡\\,≡' + .. path_sep + .. 'nvim' + .. path_sep + .. 'site' + .. path_sep + .. 'after' + .. ',\\,≡\\,≡\\,' + .. path_sep + .. 'nvim' + .. path_sep + .. 'site' + .. path_sep + .. 'after' + .. ',\\,=\\,=\\,' + .. path_sep + .. data_dir + .. path_sep + .. 'site' + .. path_sep + .. 'after' + .. ',-\\,-\\,-' + .. path_sep + .. 'nvim' + .. path_sep + .. 'after' + .. ',\\,-\\,-\\,' + .. path_sep + .. 'nvim' + .. path_sep + .. 'after' + .. ',\\, \\, \\,' + .. path_sep + .. 'nvim' + .. path_sep + .. 'after' + ), + meths.get_option_value('runtimepath', {}) + ) meths.command('set runtimepath&') meths.command('set backupdir&') meths.command('set directory&') meths.command('set undodir&') meths.command('set viewdir&') - eq(('\\, \\, \\,' .. path_sep .. 'nvim' - .. ',\\,-\\,-\\,' .. path_sep ..'nvim' - .. ',-\\,-\\,-' .. path_sep ..'nvim' - .. ',\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'site' - .. ',\\,≡\\,≡\\,' .. path_sep ..'nvim' .. path_sep ..'site' - .. ',≡\\,≡\\,≡' .. path_sep ..'nvim' .. path_sep ..'site' - .. ',' .. vimruntime - .. ',' .. libdir - .. ',≡\\,≡\\,≡' .. path_sep ..'nvim' .. path_sep ..'site' .. path_sep ..'after' - .. ',\\,≡\\,≡\\,' .. path_sep ..'nvim' .. path_sep ..'site' .. path_sep ..'after' - .. ',\\,=\\,=\\,' .. path_sep ..'' .. data_dir .. '' .. path_sep ..'site' .. path_sep ..'after' - .. ',-\\,-\\,-' .. path_sep ..'nvim' .. path_sep ..'after' - .. ',\\,-\\,-\\,' .. path_sep ..'nvim' .. path_sep ..'after' - .. ',\\, \\, \\,' .. path_sep ..'nvim' .. path_sep ..'after' - ), meths.get_option_value('runtimepath', {})) - eq('.,\\,=\\,=\\,' .. path_sep .. state_dir .. '' .. path_sep ..'backup' .. (path_sep):rep(2), - meths.get_option_value('backupdir', {})) - eq('\\,=\\,=\\,' .. path_sep ..'' .. state_dir .. '' .. path_sep ..'swap' .. (path_sep):rep(2), - meths.get_option_value('directory', {})) - eq('\\,=\\,=\\,' .. path_sep ..'' .. state_dir .. '' .. path_sep ..'undo' .. (path_sep):rep(2), - meths.get_option_value('undodir', {})) - eq('\\,=\\,=\\,' .. path_sep ..'' .. state_dir .. '' .. path_sep ..'view' .. (path_sep):rep(2), - meths.get_option_value('viewdir', {})) + eq( + ( + '\\, \\, \\,' + .. path_sep + .. 'nvim' + .. ',\\,-\\,-\\,' + .. path_sep + .. 'nvim' + .. ',-\\,-\\,-' + .. path_sep + .. 'nvim' + .. ',\\,=\\,=\\,' + .. path_sep + .. '' + .. data_dir + .. '' + .. path_sep + .. 'site' + .. ',\\,≡\\,≡\\,' + .. path_sep + .. 'nvim' + .. path_sep + .. 'site' + .. ',≡\\,≡\\,≡' + .. path_sep + .. 'nvim' + .. path_sep + .. 'site' + .. ',' + .. vimruntime + .. ',' + .. libdir + .. ',≡\\,≡\\,≡' + .. path_sep + .. 'nvim' + .. path_sep + .. 'site' + .. path_sep + .. 'after' + .. ',\\,≡\\,≡\\,' + .. path_sep + .. 'nvim' + .. path_sep + .. 'site' + .. path_sep + .. 'after' + .. ',\\,=\\,=\\,' + .. path_sep + .. '' + .. data_dir + .. '' + .. path_sep + .. 'site' + .. path_sep + .. 'after' + .. ',-\\,-\\,-' + .. path_sep + .. 'nvim' + .. path_sep + .. 'after' + .. ',\\,-\\,-\\,' + .. path_sep + .. 'nvim' + .. path_sep + .. 'after' + .. ',\\, \\, \\,' + .. path_sep + .. 'nvim' + .. path_sep + .. 'after' + ), + meths.get_option_value('runtimepath', {}) + ) + eq( + '.,\\,=\\,=\\,' .. path_sep .. state_dir .. '' .. path_sep .. 'backup' .. (path_sep):rep(2), + meths.get_option_value('backupdir', {}) + ) + eq( + '\\,=\\,=\\,' + .. path_sep + .. '' + .. state_dir + .. '' + .. path_sep + .. 'swap' + .. (path_sep):rep(2), + meths.get_option_value('directory', {}) + ) + eq( + '\\,=\\,=\\,' + .. path_sep + .. '' + .. state_dir + .. '' + .. path_sep + .. 'undo' + .. (path_sep):rep(2), + meths.get_option_value('undodir', {}) + ) + eq( + '\\,=\\,=\\,' + .. path_sep + .. '' + .. state_dir + .. '' + .. path_sep + .. 'view' + .. (path_sep):rep(2), + meths.get_option_value('viewdir', {}) + ) end) end) end) - describe('stdpath()', function() -- Windows appends 'nvim-data' instead of just 'nvim' to prevent collisions -- due to XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME being the same. @@ -584,7 +876,7 @@ describe('stdpath()', function() local env_sep = is_os('win') and ';' or ':' it('acceptance', function() - clear() -- Do not explicitly set any env vars. + clear() -- Do not explicitly set any env vars. eq('nvim', funcs.fnamemodify(funcs.stdpath('cache'), ':t')) eq('nvim', funcs.fnamemodify(funcs.stdpath('config'), ':t')) @@ -593,12 +885,12 @@ describe('stdpath()', function() eq('table', type(funcs.stdpath('config_dirs'))) eq('table', type(funcs.stdpath('dat |