aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/api')
-rw-r--r--test/functional/api/buffer_spec.lua24
-rw-r--r--test/functional/api/extmark_spec.lua4
-rw-r--r--test/functional/api/highlight_spec.lua4
-rw-r--r--test/functional/api/vim_spec.lua88
-rw-r--r--test/functional/api/window_spec.lua26
5 files changed, 69 insertions, 77 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua
index d454765edb..df9092fa14 100644
--- a/test/functional/api/buffer_spec.lua
+++ b/test/functional/api/buffer_spec.lua
@@ -630,19 +630,19 @@ describe('api/buf', function()
eq('Index out of bounds', pcall_err(get_offset, 6))
eq('Index out of bounds', pcall_err(get_offset, -1))
- curbufmeths.set_option('eol', false)
- curbufmeths.set_option('fixeol', false)
+ meths.set_option_value('eol', false, {buf=0})
+ meths.set_option_value('fixeol', false, {buf=0})
eq(28, get_offset(5))
-- fileformat is ignored
- curbufmeths.set_option('fileformat', 'dos')
+ meths.set_option_value('fileformat', 'dos', {buf=0})
eq(0, get_offset(0))
eq(6, get_offset(1))
eq(15, get_offset(2))
eq(16, get_offset(3))
eq(24, get_offset(4))
eq(28, get_offset(5))
- curbufmeths.set_option('eol', true)
+ meths.set_option_value('eol', true, {buf=0})
eq(29, get_offset(5))
command("set hidden")
@@ -697,23 +697,23 @@ describe('api/buf', function()
end)
end)
- describe('nvim_buf_get_option, nvim_buf_set_option', function()
+ describe('nvim_get_option_value, nvim_set_option_value', function()
it('works', function()
- eq(8, curbuf('get_option', 'shiftwidth'))
- curbuf('set_option', 'shiftwidth', 4)
- eq(4, curbuf('get_option', 'shiftwidth'))
+ eq(8, nvim('get_option_value', 'shiftwidth', {buf = 0}))
+ nvim('set_option_value', 'shiftwidth', 4, {buf=0})
+ eq(4, nvim('get_option_value', 'shiftwidth', {buf = 0}))
-- global-local option
- curbuf('set_option', 'define', 'test')
- eq('test', curbuf('get_option', 'define'))
+ nvim('set_option_value', 'define', 'test', {buf = 0})
+ eq('test', nvim('get_option_value', 'define', {buf = 0}))
-- Doesn't change the global value
- eq([[^\s*#\s*define]], nvim('get_option', 'define'))
+ eq([[^\s*#\s*define]], nvim('get_option_value', 'define', {scope='global'}))
end)
it('returns values for unset local options', function()
-- 'undolevels' is only set to its "unset" value when a new buffer is
-- created
command('enew')
- eq(-123456, curbuf('get_option', 'undolevels'))
+ eq(-123456, nvim('get_option_value', 'undolevels', {buf=0}))
end)
end)
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index e30ffc92b6..0960e910f1 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -1401,7 +1401,7 @@ describe('API/extmarks', function()
it('in read-only buffer', function()
command("view! runtime/doc/help.txt")
- eq(true, curbufmeths.get_option('ro'))
+ eq(true, meths.get_option_value('ro', {buf=0}))
local id = set_extmark(ns, 0, 0, 2)
eq({{id, 0, 2}}, get_extmarks(ns,0, -1))
end)
@@ -1474,7 +1474,7 @@ describe('API/extmarks', function()
it('in prompt buffer', function()
feed('dd')
local id = set_extmark(ns, marks[1], 0, 0, {})
- curbufmeths.set_option('buftype', 'prompt')
+ meths.set_option_value('buftype', 'prompt', {buf = 0})
feed('i<esc>')
eq({{id, 0, 2}}, get_extmarks(ns, 0, -1))
end)
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index a6e9f9a42b..1601184e1b 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -155,9 +155,9 @@ describe('API: highlight',function()
it("nvim_buf_add_highlight to other buffer doesn't crash if undo is disabled #12873", function()
command('vsplit file')
- local err, _ = pcall(meths.buf_set_option, 1, 'undofile', false)
+ local err, _ = pcall(meths.set_option_value, 'undofile', false, { buf = 1 })
eq(true, err)
- err, _ = pcall(meths.buf_set_option, 1, 'undolevels', -1)
+ err, _ = pcall(meths.set_option_value, 'undolevels', -1, { buf = 1 })
eq(true, err)
err, _ = pcall(meths.buf_add_highlight, 1, -1, 'Question', 0, 0, -1)
eq(true, err)
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index c81b6e90cc..5b8b52a559 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1051,7 +1051,7 @@ describe('API', function()
line 3
]])
eq({0,4,1,0}, funcs.getpos('.')) -- Cursor follows the paste.
- eq(false, nvim('get_option', 'paste'))
+ eq(false, nvim('get_option_value', 'paste', {}))
command('%delete _')
-- Without final "\n".
nvim('paste', 'line 1\nline 2\nline 3', true, -1)
@@ -1091,7 +1091,7 @@ describe('API', function()
nvim('paste', 'line 1\r\n\r\rline 2\nline 3\rline 4\r', true, -1)
expect('line 1\n\n\nline 2\nline 3\nline 4\n')
eq({0,7,1,0}, funcs.getpos('.'))
- eq(false, nvim('get_option', 'paste'))
+ eq(false, nvim('get_option_value', 'paste', {}))
end)
it('Replace-mode', function()
-- Within single line
@@ -1382,44 +1382,38 @@ describe('API', function()
end)
end)
- describe('nvim_get_option, nvim_set_option', function()
+ describe('nvim_get_option_value, nvim_set_option_value', function()
it('works', function()
- ok(nvim('get_option', 'equalalways'))
- nvim('set_option', 'equalalways', false)
- ok(not nvim('get_option', 'equalalways'))
+ ok(nvim('get_option_value', 'equalalways', {}))
+ nvim('set_option_value', 'equalalways', false, {})
+ ok(not nvim('get_option_value', 'equalalways', {}))
end)
it('works to get global value of local options', function()
- eq(false, nvim('get_option', 'lisp'))
- eq(8, nvim('get_option', 'shiftwidth'))
+ eq(false, nvim('get_option_value', 'lisp', {}))
+ eq(8, nvim('get_option_value', 'shiftwidth', {}))
end)
it('works to set global value of local options', function()
- nvim('set_option', 'lisp', true)
- eq(true, nvim('get_option', 'lisp'))
- eq(false, helpers.curbuf('get_option', 'lisp'))
+ nvim('set_option_value', 'lisp', true, {scope='global'})
+ eq(true, nvim('get_option_value', 'lisp', {scope='global'}))
+ eq(false, nvim('get_option_value', 'lisp', {buf=0}))
eq(nil, nvim('command_output', 'setglobal lisp?'):match('nolisp'))
eq('nolisp', nvim('command_output', 'setlocal lisp?'):match('nolisp'))
- nvim('set_option', 'shiftwidth', 20)
+ nvim('set_option_value', 'shiftwidth', 20, {scope='global'})
eq('20', nvim('command_output', 'setglobal shiftwidth?'):match('%d+'))
eq('8', nvim('command_output', 'setlocal shiftwidth?'):match('%d+'))
end)
- it('most window-local options have no global value', function()
- local status, err = pcall(nvim, 'get_option', 'foldcolumn')
- eq(false, status)
- ok(err:match('Invalid option name') ~= nil)
- end)
-
it('updates where the option was last set from', function()
- nvim('set_option', 'equalalways', false)
+ nvim('set_option_value', 'equalalways', false, {})
local status, rv = pcall(nvim, 'command_output',
'verbose set equalalways?')
eq(true, status)
ok(nil ~= string.find(rv, 'noequalalways\n'..
'\tLast set from API client %(channel id %d+%)'))
- nvim('exec_lua', 'vim.api.nvim_set_option("equalalways", true)', {})
+ nvim('exec_lua', 'vim.api.nvim_set_option_value("equalalways", true, {})', {})
status, rv = pcall(nvim, 'command_output',
'verbose set equalalways?')
eq(true, status)
@@ -1499,7 +1493,6 @@ describe('API', function()
end)
it('set window options', function()
- -- Same as to nvim_win_set_option
nvim('set_option_value', 'colorcolumn', '4,3', {win=0})
eq('4,3', nvim('get_option_value', 'colorcolumn', {scope = 'local'}))
command("set modified hidden")
@@ -1508,7 +1501,6 @@ describe('API', function()
end)
it('set local window options', function()
- -- Different to nvim_win_set_option
nvim('set_option_value', 'colorcolumn', '4,3', {win=0, scope='local'})
eq('4,3', nvim('get_option_value', 'colorcolumn', {win = 0, scope = 'local'}))
command("set modified hidden")
@@ -1519,11 +1511,11 @@ describe('API', function()
it('get buffer or window-local options', function()
nvim('command', 'new')
local buf = nvim('get_current_buf').id
- nvim('buf_set_option', buf, 'tagfunc', 'foobar')
+ nvim('set_option_value', 'tagfunc', 'foobar', {buf=buf})
eq('foobar', nvim('get_option_value', 'tagfunc', {buf = buf}))
local win = nvim('get_current_win').id
- nvim('win_set_option', win, 'number', true)
+ nvim('set_option_value', 'number', true, {win=win})
eq(true, nvim('get_option_value', 'number', {win = win}))
end)
@@ -2215,7 +2207,7 @@ describe('API', function()
it('stream=job :terminal channel', function()
command(':terminal')
eq({id=1}, meths.get_current_buf())
- eq(3, meths.buf_get_option(1, 'channel'))
+ eq(3, meths.get_option_value('channel', {buf=1}))
local info = {
stream='job',
@@ -2368,45 +2360,45 @@ describe('API', function()
end)
it('returns nothing with empty &runtimepath', function()
- meths.set_option('runtimepath', '')
+ meths.set_option_value('runtimepath', '', {})
eq({}, meths.list_runtime_paths())
end)
it('returns single runtimepath', function()
- meths.set_option('runtimepath', 'a')
+ meths.set_option_value('runtimepath', 'a', {})
eq({'a'}, meths.list_runtime_paths())
end)
it('returns two runtimepaths', function()
- meths.set_option('runtimepath', 'a,b')
+ meths.set_option_value('runtimepath', 'a,b', {})
eq({'a', 'b'}, meths.list_runtime_paths())
end)
it('returns empty strings when appropriate', function()
- meths.set_option('runtimepath', 'a,,b')
+ meths.set_option_value('runtimepath', 'a,,b', {})
eq({'a', '', 'b'}, meths.list_runtime_paths())
- meths.set_option('runtimepath', ',a,b')
+ meths.set_option_value('runtimepath', ',a,b', {})
eq({'', 'a', 'b'}, meths.list_runtime_paths())
-- Trailing "," is ignored. Use ",," if you really really want CWD.
- meths.set_option('runtimepath', 'a,b,')
+ meths.set_option_value('runtimepath', 'a,b,', {})
eq({'a', 'b'}, meths.list_runtime_paths())
- meths.set_option('runtimepath', 'a,b,,')
+ meths.set_option_value('runtimepath', 'a,b,,', {})
eq({'a', 'b', ''}, meths.list_runtime_paths())
end)
it('truncates too long paths', function()
local long_path = ('/a'):rep(8192)
- meths.set_option('runtimepath', long_path)
+ meths.set_option_value('runtimepath', long_path, {})
local paths_list = meths.list_runtime_paths()
eq({}, paths_list)
end)
end)
it('can throw exceptions', function()
- local status, err = pcall(nvim, 'get_option', 'invalid-option')
+ local status, err = pcall(nvim, 'get_option_value', 'invalid-option', {})
eq(false, status)
- ok(err:match('Invalid option name') ~= nil)
+ ok(err:match("Invalid 'option': 'invalid%-option'") ~= nil)
end)
it('does not truncate error message <1 MB #5984', function()
local very_long_name = 'A'..('x'):rep(10000)..'Z'
- local status, err = pcall(nvim, 'get_option', very_long_name)
+ local status, err = pcall(nvim, 'get_option_value', very_long_name, {})
eq(false, status)
eq(very_long_name, err:match('Ax+Z?'))
end)
@@ -2419,7 +2411,7 @@ describe('API', function()
describe('nvim_parse_expression', function()
before_each(function()
- meths.set_option('isident', '')
+ meths.set_option_value('isident', '', {})
end)
local function simplify_east_api_node(line, east_api_node)
@@ -2704,9 +2696,9 @@ describe('API', function()
end)
it('can change buftype before visiting', function()
- meths.set_option("hidden", false)
+ meths.set_option_value("hidden", false, {})
eq({id=2}, meths.create_buf(true, false))
- meths.buf_set_option(2, "buftype", "nofile")
+ meths.set_option_value("buftype", "nofile", {buf=2})
meths.buf_set_lines(2, 0, -1, true, {"test text"})
command("split | buffer 2")
eq({id=2}, meths.get_current_buf())
@@ -2749,10 +2741,10 @@ describe('API', function()
local edited_buf = 2
meths.buf_set_lines(edited_buf, 0, -1, true, {"some text"})
for _,b in ipairs(scratch_bufs) do
- eq('nofile', meths.buf_get_option(b, 'buftype'))
- eq('hide', meths.buf_get_option(b, 'bufhidden'))
- eq(false, meths.buf_get_option(b, 'swapfile'))
- eq(false, meths.buf_get_option(b, 'modeline'))
+ eq('nofile', meths.get_option_value('buftype', {buf=b}))
+ eq('hide', meths.get_option_value('bufhidden', {buf=b}))
+ eq(false, meths.get_option_value('swapfile', {buf=b}))
+ eq(false, meths.get_option_value('modeline', {buf=b}))
end
--
@@ -2765,10 +2757,10 @@ describe('API', function()
{1:~ }|
|
]])
- eq('nofile', meths.buf_get_option(edited_buf, 'buftype'))
- eq('hide', meths.buf_get_option(edited_buf, 'bufhidden'))
- eq(false, meths.buf_get_option(edited_buf, 'swapfile'))
- eq(false, meths.buf_get_option(edited_buf, 'modeline'))
+ eq('nofile', meths.get_option_value('buftype', {buf=edited_buf}))
+ eq('hide', meths.get_option_value('bufhidden', {buf=edited_buf}))
+ eq(false, meths.get_option_value('swapfile', {buf=edited_buf}))
+ eq(false, meths.get_option_value('modeline', {buf=edited_buf}))
-- Scratch buffer can be wiped without error.
command('bwipe')
@@ -2899,7 +2891,7 @@ describe('API', function()
it('should have information about global options', function()
-- precondition: the option was changed from its default
-- in test setup.
- eq(false, meths.get_option'showcmd')
+ eq(false, meths.get_option_value('showcmd', {}))
eq({
allows_duplicates = true,
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index ecab6a4713..660fa4731e 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -363,22 +363,22 @@ describe('API/win', function()
end)
end)
- describe('nvim_win_get_option, nvim_win_set_option', function()
+ describe('nvim_get_option_value, nvim_set_option_value', function()
it('works', function()
- curwin('set_option', 'colorcolumn', '4,3')
- eq('4,3', curwin('get_option', 'colorcolumn'))
+ nvim('set_option_value', 'colorcolumn', '4,3', {win=0})
+ eq('4,3', nvim('get_option_value', 'colorcolumn', {win = 0}))
command("set modified hidden")
command("enew") -- edit new buffer, window option is preserved
- eq('4,3', curwin('get_option', 'colorcolumn'))
+ eq('4,3', nvim('get_option_value', 'colorcolumn', {win = 0}))
-- global-local option
- curwin('set_option', 'statusline', 'window-status')
- eq('window-status', curwin('get_option', 'statusline'))
- eq('', nvim('get_option', 'statusline'))
+ nvim('set_option_value', 'statusline', 'window-status', {win=0})
+ eq('window-status', nvim('get_option_value', 'statusline', {win=0}))
+ eq('', nvim('get_option_value', 'statusline', {scope='global'}))
command("set modified")
command("enew") -- global-local: not preserved in new buffer
-- confirm local value was not copied
- eq('', curwin('get_option', 'statusline'))
+ eq('', nvim('get_option_value', 'statusline', {win = 0}))
eq('', eval('&l:statusline'))
end)
@@ -386,16 +386,16 @@ describe('API/win', function()
nvim('command', 'tabnew')
local tab1 = unpack(nvim('list_tabpages'))
local win1 = unpack(tabpage('list_wins', tab1))
- window('set_option', win1, 'statusline', 'window-status')
+ nvim('set_option_value', 'statusline', 'window-status', {win=win1.id})
nvim('command', 'split')
nvim('command', 'wincmd J')
nvim('command', 'wincmd j')
- eq('window-status', window('get_option', win1, 'statusline'))
+ eq('window-status', nvim('get_option_value', 'statusline', {win = win1.id}))
assert_alive()
end)
it('returns values for unset local options', function()
- eq(-1, curwin('get_option', 'scrolloff'))
+ eq(-1, nvim('get_option_value', 'scrolloff', {win=0, scope='local'}))
end)
end)
@@ -568,11 +568,11 @@ describe('API/win', function()
it('deletes the buffer when bufhidden=wipe', function()
local oldwin = meths.get_current_win()
local oldbuf = meths.get_current_buf()
- local buf = meths.create_buf(true, false)
+ local buf = meths.create_buf(true, false).id
local newwin = meths.open_win(buf, true, {
relative='win', row=3, col=3, width=12, height=3
})
- meths.buf_set_option(buf, 'bufhidden', 'wipe')
+ meths.set_option_value('bufhidden', 'wipe', {buf=buf})
meths.win_hide(newwin)
eq({oldwin}, meths.list_wins())
eq({oldbuf}, meths.list_bufs())