aboutsummaryrefslogtreecommitdiff
path: root/test/functional/options
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/options')
-rw-r--r--test/functional/options/chars_spec.lua48
-rw-r--r--test/functional/options/defaults_spec.lua42
-rw-r--r--test/functional/options/keymap_spec.lua2
-rw-r--r--test/functional/options/num_options_spec.lua20
-rw-r--r--test/functional/options/shortmess_spec.lua8
5 files changed, 81 insertions, 39 deletions
diff --git a/test/functional/options/chars_spec.lua b/test/functional/options/chars_spec.lua
index 1330c29e61..5439ca3dba 100644
--- a/test/functional/options/chars_spec.lua
+++ b/test/functional/options/chars_spec.lua
@@ -16,10 +16,6 @@ describe("'fillchars'", function()
screen:attach()
end)
- after_each(function()
- screen:detach()
- end)
-
local function shouldfail(val,errval)
errval = errval or val
eq('Vim(set):E474: Invalid argument: fillchars='..errval,
@@ -71,16 +67,29 @@ describe("'fillchars'", function()
shouldfail('eob:xy') -- two ascii chars
shouldfail('eob:\255', 'eob:<ff>') -- invalid UTF-8
end)
- it('is local to window', function()
- clear()
- screen = Screen.new(50, 5)
- screen:attach()
+ it('has global value', function()
+ screen:try_resize(50, 5)
insert("foo\nbar")
command('set laststatus=0')
command('1,2fold')
command('vsplit')
command('set fillchars=fold:x')
screen:expect([[
+ ^+-- 2 lines: fooxxxxxxxx│+-- 2 lines: fooxxxxxxx|
+ ~ │~ |
+ ~ │~ |
+ ~ │~ |
+ |
+ ]])
+ end)
+ it('has local window value', function()
+ screen:try_resize(50, 5)
+ insert("foo\nbar")
+ command('set laststatus=0')
+ command('1,2fold')
+ command('vsplit')
+ command('setl fillchars=fold:x')
+ screen:expect([[
^+-- 2 lines: fooxxxxxxxx│+-- 2 lines: foo·······|
~ │~ |
~ │~ |
@@ -100,16 +109,25 @@ describe("'listchars'", function()
screen:attach()
end)
- after_each(function()
- screen:detach()
+ it('has global value', function()
+ feed('i<tab><tab><tab><esc>')
+ command('set list laststatus=0')
+ command('vsplit')
+ command('set listchars=tab:<->')
+ screen:expect([[
+ <------><------>^<------> │<------><------><------>|
+ ~ │~ |
+ ~ │~ |
+ ~ │~ |
+ |
+ ]])
end)
-
- it('is local to window', function()
+ it('has value local to window', function()
feed('i<tab><tab><tab><esc>')
- command('set laststatus=0')
- command('set list listchars=tab:<->')
+ command('set list laststatus=0')
+ command('setl listchars=tab:<->')
command('vsplit')
- command('set listchars&')
+ command('setl listchars<')
screen:expect([[
> > ^> │<------><------><------>|
~ │~ |
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index 490a04186d..11ce26410d 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -224,9 +224,6 @@ describe('startup defaults', function()
XDG_DATA_HOME=xdgdir,
NVIM_LOG_FILE='', -- Empty is invalid.
}})
- -- server_start() calls ELOG, which tickles log_path_init().
- pcall(command, 'call serverstart(serverlist()[0])')
-
eq(xdgdir..'/'..datasubdir..'/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/'))
end)
it('defaults to stdpath("data")/log if invalid', function()
@@ -235,9 +232,6 @@ describe('startup defaults', function()
XDG_DATA_HOME=xdgdir,
NVIM_LOG_FILE='.', -- Any directory is invalid.
}})
- -- server_start() calls ELOG, which tickles log_path_init().
- pcall(command, 'call serverstart(serverlist()[0])')
-
eq(xdgdir..'/'..datasubdir..'/log', string.gsub(eval('$NVIM_LOG_FILE'), '\\', '/'))
end)
it('defaults to .nvimlog if stdpath("data") is invalid', function()
@@ -245,9 +239,6 @@ describe('startup defaults', function()
XDG_DATA_HOME='Xtest-missing-xdg-dir',
NVIM_LOG_FILE='.', -- Any directory is invalid.
}})
- -- server_start() calls ELOG, which tickles log_path_init().
- pcall(command, 'call serverstart(serverlist()[0])')
-
eq('.nvimlog', eval('$NVIM_LOG_FILE'))
end)
end)
@@ -302,6 +293,14 @@ describe('XDG-based defaults', function()
-- TODO(jkeyes): tests below fail on win32 because of path separator.
if helpers.pending_win32(pending) then return end
+ local function vimruntime_and_libdir()
+ local vimruntime = eval('$VIMRUNTIME')
+ -- libdir is hard to calculate reliably across various ci platforms
+ -- local libdir = string.gsub(vimruntime, "share/nvim/runtime$", "lib/nvim")
+ local libdir = meths._get_lib_dir()
+ return vimruntime, libdir
+ end
+
describe('with too long XDG variables', function()
before_each(function()
clear({env={
@@ -317,6 +316,8 @@ describe('XDG-based defaults', function()
end)
it('are correctly set', function()
+ local vimruntime, libdir = vimruntime_and_libdir()
+
eq((('/x'):rep(4096) .. '/nvim'
.. ',' .. ('/a'):rep(2048) .. '/nvim'
.. ',' .. ('/b'):rep(2048) .. '/nvim'
@@ -325,7 +326,8 @@ describe('XDG-based defaults', function()
.. ',' .. ('/A'):rep(2048) .. '/nvim/site'
.. ',' .. ('/B'):rep(2048) .. '/nvim/site'
.. (',' .. '/C/nvim/site'):rep(512)
- .. ',' .. eval('$VIMRUNTIME')
+ .. ',' .. vimruntime
+ .. ',' .. libdir
.. (',' .. '/C/nvim/site/after'):rep(512)
.. ',' .. ('/B'):rep(2048) .. '/nvim/site/after'
.. ',' .. ('/A'):rep(2048) .. '/nvim/site/after'
@@ -348,7 +350,8 @@ describe('XDG-based defaults', function()
.. ',' .. ('/A'):rep(2048) .. '/nvim/site'
.. ',' .. ('/B'):rep(2048) .. '/nvim/site'
.. (',' .. '/C/nvim/site'):rep(512)
- .. ',' .. eval('$VIMRUNTIME')
+ .. ',' .. vimruntime
+ .. ',' .. libdir
.. (',' .. '/C/nvim/site/after'):rep(512)
.. ',' .. ('/B'):rep(2048) .. '/nvim/site/after'
.. ',' .. ('/A'):rep(2048) .. '/nvim/site/after'
@@ -377,11 +380,13 @@ describe('XDG-based defaults', function()
end)
it('are not expanded', function()
+ local vimruntime, libdir = vimruntime_and_libdir()
eq(('$XDG_DATA_HOME/nvim'
.. ',$XDG_DATA_DIRS/nvim'
.. ',$XDG_CONFIG_HOME/nvim/site'
.. ',$XDG_CONFIG_DIRS/nvim/site'
- .. ',' .. eval('$VIMRUNTIME')
+ .. ',' .. vimruntime
+ .. ',' .. libdir
.. ',$XDG_CONFIG_DIRS/nvim/site/after'
.. ',$XDG_CONFIG_HOME/nvim/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
@@ -396,7 +401,8 @@ describe('XDG-based defaults', function()
.. ',$XDG_DATA_DIRS/nvim'
.. ',$XDG_CONFIG_HOME/nvim/site'
.. ',$XDG_CONFIG_DIRS/nvim/site'
- .. ',' .. eval('$VIMRUNTIME')
+ .. ',' .. vimruntime
+ .. ',' .. libdir
.. ',$XDG_CONFIG_DIRS/nvim/site/after'
.. ',$XDG_CONFIG_HOME/nvim/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
@@ -411,7 +417,8 @@ describe('XDG-based defaults', function()
.. ',$XDG_DATA_DIRS/nvim'
.. ',$XDG_CONFIG_HOME/nvim/site'
.. ',$XDG_CONFIG_DIRS/nvim/site'
- .. ',' .. eval('$VIMRUNTIME')
+ .. ',' .. vimruntime
+ .. ',' .. libdir
.. ',$XDG_CONFIG_DIRS/nvim/site/after'
.. ',$XDG_CONFIG_HOME/nvim/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
@@ -435,13 +442,15 @@ describe('XDG-based defaults', function()
end)
it('are escaped properly', function()
+ local vimruntime, libdir = vimruntime_and_libdir()
eq(('\\, \\, \\,/nvim'
.. ',\\,-\\,-\\,/nvim'
.. ',-\\,-\\,-/nvim'
.. ',\\,=\\,=\\,/nvim/site'
.. ',\\,≡\\,≡\\,/nvim/site'
.. ',≡\\,≡\\,≡/nvim/site'
- .. ',' .. eval('$VIMRUNTIME')
+ .. ',' .. vimruntime
+ .. ',' .. libdir
.. ',≡\\,≡\\,≡/nvim/site/after'
.. ',\\,≡\\,≡\\,/nvim/site/after'
.. ',\\,=\\,=\\,/nvim/site/after'
@@ -460,7 +469,8 @@ describe('XDG-based defaults', function()
.. ',\\,=\\,=\\,/nvim/site'
.. ',\\,≡\\,≡\\,/nvim/site'
.. ',≡\\,≡\\,≡/nvim/site'
- .. ',' .. eval('$VIMRUNTIME')
+ .. ',' .. vimruntime
+ .. ',' .. libdir
.. ',≡\\,≡\\,≡/nvim/site/after'
.. ',\\,≡\\,≡\\,/nvim/site/after'
.. ',\\,=\\,=\\,/nvim/site/after'
diff --git a/test/functional/options/keymap_spec.lua b/test/functional/options/keymap_spec.lua
index 7f6d623dc7..52a714f7a8 100644
--- a/test/functional/options/keymap_spec.lua
+++ b/test/functional/options/keymap_spec.lua
@@ -30,7 +30,7 @@ describe("'keymap' / :lmap", function()
command('lmapclear <buffer>')
command('set keymap=dvorak')
command('set nomore')
- local bindings = funcs.nvim_command_output('lmap')
+ local bindings = funcs.nvim_exec('lmap', true)
eq(dedent([[
l " @_
diff --git a/test/functional/options/num_options_spec.lua b/test/functional/options/num_options_spec.lua
index deda5c9118..4754c14f5b 100644
--- a/test/functional/options/num_options_spec.lua
+++ b/test/functional/options/num_options_spec.lua
@@ -65,14 +65,12 @@ describe(':set validation', function()
should_succeed('regexpengine', 2)
should_fail('report', -1, 'E487')
should_succeed('report', 0)
- should_fail('scrolloff', -1, 'E49')
- should_fail('sidescrolloff', -1, 'E487')
should_fail('sidescroll', -1, 'E487')
should_fail('cmdwinheight', 0, 'E487')
should_fail('updatetime', -1, 'E487')
should_fail('foldlevel', -5, 'E487')
- should_fail('foldcolumn', 13, 'E474')
+ should_fail('foldcolumn', '13', 'E474')
should_fail('conceallevel', 4, 'E474')
should_fail('numberwidth', 21, 'E474')
should_fail('numberwidth', 0, 'E487')
@@ -82,6 +80,22 @@ describe(':set validation', function()
meths.set_option('window', -10)
eq(23, meths.get_option('window'))
eq('', eval("v:errmsg"))
+
+ -- 'scrolloff' and 'sidescrolloff' can have a -1 value when
+ -- set for the current window, but not globally
+ feed_command('setglobal scrolloff=-1')
+ eq('E487', eval("v:errmsg"):match("E%d*"))
+
+ feed_command('setglobal sidescrolloff=-1')
+ eq('E487', eval("v:errmsg"):match("E%d*"))
+
+ feed_command('let v:errmsg=""')
+
+ feed_command('setlocal scrolloff=-1')
+ eq('', eval("v:errmsg"))
+
+ feed_command('setlocal sidescrolloff=-1')
+ eq('', eval("v:errmsg"))
end)
it('set wmh/wh wmw/wiw checks', function()
diff --git a/test/functional/options/shortmess_spec.lua b/test/functional/options/shortmess_spec.lua
index 8ea9a19464..a56e9c09b4 100644
--- a/test/functional/options/shortmess_spec.lua
+++ b/test/functional/options/shortmess_spec.lua
@@ -25,7 +25,7 @@ describe("'shortmess'", function()
~ |
~ |
~ |
- "foo" [New File] |
+ "foo" [New] |
]])
eq(1, eval('bufnr("%")'))
@@ -50,7 +50,7 @@ describe("'shortmess'", function()
~ |
~ |
~ |
- "foo" [New File] |
+ "foo" [New] |
]])
eq(1, eval('bufnr("%")'))
feed(':edit bar<CR>')
@@ -59,7 +59,7 @@ describe("'shortmess'", function()
~ |
~ |
~ |
- "bar" [New File] |
+ "bar" [New] |
]])
eq(2, eval('bufnr("%")'))
feed(':bprevious<CR>')
@@ -68,7 +68,7 @@ describe("'shortmess'", function()
~ |
~ |
~ |
- "foo" [New file] --No lines in buffer-- |
+ "foo" [New] --No lines in buffer-- |
]])
eq(1, eval('bufnr("%")'))