refactor(options): deprecate nvim[_buf|_win]_[gs]et_option

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: famiu <famiuhaque@protonmail.com>
This commit is contained in:
Lewis Russell 2022-12-19 16:37:45 +00:00 committed by Famiu Haque
parent e3e6fadfd8
commit 1fe1bb084d
87 changed files with 725 additions and 785 deletions

View File

@ -486,7 +486,7 @@ Example: create a float with scratch buffer: >vim
\ 'row': 1, 'anchor': 'NW', 'style': 'minimal'}
let win = nvim_open_win(buf, 0, opts)
" optional: change highlight, otherwise Pmenu is used
call nvim_win_set_option(win, 'winhl', 'Normal:MyHighlight')
call nvim_set_option_value('winhl', 'Normal:MyHighlight', {'win': win})
<
==============================================================================
@ -1917,25 +1917,6 @@ nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
==============================================================================
Options Functions *api-options*
nvim_buf_get_option({buffer}, {name}) *nvim_buf_get_option()*
Gets a buffer option value
Parameters: ~
• {buffer} Buffer handle, or 0 for current buffer
• {name} Option name
Return: ~
Option value
nvim_buf_set_option({buffer}, {name}, {value}) *nvim_buf_set_option()*
Sets a buffer option value. Passing `nil` as value deletes the option
(only works if there's a global fallback)
Parameters: ~
• {buffer} Buffer handle, or 0 for current buffer
• {name} Option name
• {value} Option value
nvim_get_all_options_info() *nvim_get_all_options_info()*
Gets the option information for all options.
@ -1945,15 +1926,6 @@ nvim_get_all_options_info() *nvim_get_all_options_info()*
Return: ~
dictionary of all options
nvim_get_option({name}) *nvim_get_option()*
Gets the global value of an option.
Parameters: ~
• {name} Option name
Return: ~
Option value (global)
nvim_get_option_info2({name}, {*opts}) *nvim_get_option_info2()*
Gets the option information for one option from arbitrary buffer or window
@ -2010,13 +1982,6 @@ nvim_get_option_value({name}, {*opts}) *nvim_get_option_value()*
Return: ~
Option value
nvim_set_option({name}, {value}) *nvim_set_option()*
Sets the global value of an option.
Parameters: ~
• {name} Option name
• {value} New option value
*nvim_set_option_value()*
nvim_set_option_value({name}, {value}, {*opts})
Sets the value of an option. The behavior of this function matches that of
@ -2034,25 +1999,6 @@ nvim_set_option_value({name}, {value}, {*opts})
• win: |window-ID|. Used for setting window local option.
• buf: Buffer number. Used for setting buffer local option.
nvim_win_get_option({window}, {name}) *nvim_win_get_option()*
Gets a window option value
Parameters: ~
• {window} Window handle, or 0 for current window
• {name} Option name
Return: ~
Option value
nvim_win_set_option({window}, {name}, {value}) *nvim_win_set_option()*
Sets a window option value. Passing `nil` as value deletes the option
(only works if there's a global fallback)
Parameters: ~
• {window} Window handle, or 0 for current window
• {name} Option name
• {value} Option value
==============================================================================
Buffer Functions *api-buffer*

View File

@ -21,6 +21,12 @@ API
- *nvim_get_hl_by_id()* Use |nvim_get_hl()| instead.
- *nvim_exec()* Use |nvim_exec2()| instead.
- *nvim_get_option_info()* Use |nvim_get_option_info2()| instead.
- *nvim_buf_get_option()* Use |nvim_get_option_value()| instead.
- *nvim_buf_set_option()* Use |nvim_set_option_value()| instead.
- *nvim_get_option()* Use |nvim_get_option_value()| instead.
- *nvim_set_option()* Use |nvim_set_option_value()| instead.
- *nvim_win_get_option()* Use |nvim_get_option_value()| instead.
- *nvim_win_set_option()* Use |nvim_set_option_value()| instead.
COMMANDS
- *:rv* *:rviminfo* Deprecated alias to |:rshada| command.

View File

@ -800,8 +800,8 @@ formatexpr({opts}) *vim.lsp.formatexpr()*
Currently only supports a single client. This can be set via `setlocal
formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in
`on_attach` via `vim.api.nvim_buf_set_option(bufnr, 'formatexpr',
'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')`.
`on_attach` via `vim.bo[bufnr].formatexpr =
'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})'`.
Parameters: ~
• {opts} (table) options for customizing the formatting expression

View File

@ -401,7 +401,7 @@ For example consider the following Lua omnifunc handler: >lua
return {'stuff', 'steam', 'strange things'}
end
end
vim.api.nvim_buf_set_option(0, 'omnifunc', 'v:lua.mymod.omnifunc')
vim.bo[buf].omnifunc = 'v:lua.mymod.omnifunc'
Note: The module ("mymod" in the above example) must either be a Lua global,
or use require() as shown above to access it from a package.

View File

@ -84,7 +84,7 @@ The following deprecated functions or APIs were removed.
==============================================================================
DEPRECATIONS *news-deprecations*
The following functions are now deprecated and will be removed in the next
The following functions are now deprecated and will be removed in a future
release.
• Checkhealth functions:
@ -94,4 +94,12 @@ release.
- |health#report_start|, |vim.health.report_start()| Use |vim.health.start()| instead.
- |health#report_warn|, |vim.health.report_warn()| Use |vim.health.warn()| instead.
• |API| functions:
- |nvim_buf_get_option()| Use |nvim_get_option_value()| instead.
- |nvim_buf_set_option()| Use |nvim_set_option_value()| instead.
- |nvim_get_option()| Use |nvim_get_option_value()| instead.
- |nvim_set_option()| Use |nvim_set_option_value()| instead.
- |nvim_win_get_option()| Use |nvim_get_option_value()| instead.
- |nvim_win_set_option()| Use |nvim_set_option_value()| instead.
vim:tw=78:ts=8:sw=2:et:ft=help:norl:

View File

@ -8,12 +8,8 @@ local sync = require('vim.lsp.sync')
local semantic_tokens = require('vim.lsp.semantic_tokens')
local api = vim.api
local nvim_err_writeln, nvim_buf_get_lines, nvim_command, nvim_buf_get_option, nvim_exec_autocmds =
api.nvim_err_writeln,
api.nvim_buf_get_lines,
api.nvim_command,
api.nvim_buf_get_option,
api.nvim_exec_autocmds
local nvim_err_writeln, nvim_buf_get_lines, nvim_command, nvim_exec_autocmds =
api.nvim_err_writeln, api.nvim_buf_get_lines, api.nvim_command, api.nvim_exec_autocmds
local uv = vim.loop
local tbl_isempty, tbl_extend = vim.tbl_isempty, vim.tbl_extend
local validate = vim.validate
@ -137,7 +133,7 @@ local format_line_ending = {
---@param bufnr (number)
---@return string
local function buf_get_line_ending(bufnr)
return format_line_ending[nvim_buf_get_option(bufnr, 'fileformat')] or '\n'
return format_line_ending[vim.bo[bufnr].fileformat] or '\n'
end
local client_index = 0
@ -319,7 +315,7 @@ end
local function buf_get_full_text(bufnr)
local line_ending = buf_get_line_ending(bufnr)
local text = table.concat(nvim_buf_get_lines(bufnr, 0, -1, true), line_ending)
if nvim_buf_get_option(bufnr, 'eol') then
if vim.bo[bufnr].eol then
text = text .. line_ending
end
return text
@ -709,7 +705,7 @@ local function text_document_did_open_handler(bufnr, client)
if not api.nvim_buf_is_loaded(bufnr) then
return
end
local filetype = nvim_buf_get_option(bufnr, 'filetype')
local filetype = vim.bo[bufnr].filetype
local params = {
textDocument = {
@ -2177,7 +2173,7 @@ end
---
--- Currently only supports a single client. This can be set via
--- `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in `on_attach`
--- via ``vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')``.
--- via ``vim.bo[bufnr].formatexpr = 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})'``.
---
---@param opts table options for customizing the formatting expression which takes the
--- following optional keys:

View File

@ -454,7 +454,7 @@ function M.signature_help(_, result, ctx, config)
local client = vim.lsp.get_client_by_id(ctx.client_id)
local triggers =
vim.tbl_get(client.server_capabilities, 'signatureHelpProvider', 'triggerCharacters')
local ft = api.nvim_buf_get_option(ctx.bufnr, 'filetype')
local ft = vim.bo[ctx.bufnr].filetype
local lines, hl = util.convert_signature_help_to_markdown_lines(result, ft, triggers)
lines = util.trim_empty_lines(lines)
if vim.tbl_isempty(lines) then

View File

@ -401,7 +401,7 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding)
if not api.nvim_buf_is_loaded(bufnr) then
vim.fn.bufload(bufnr)
end
api.nvim_buf_set_option(bufnr, 'buflisted', true)
vim.bo[bufnr].buflisted = true
-- Fix reversed range and indexing each text_edits
local index = 0
@ -530,11 +530,7 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding)
-- Remove final line if needed
local fix_eol = has_eol_text_edit
fix_eol = fix_eol
and (
api.nvim_buf_get_option(bufnr, 'eol')
or (api.nvim_buf_get_option(bufnr, 'fixeol') and not api.nvim_buf_get_option(bufnr, 'binary'))
)
fix_eol = fix_eol and (vim.bo[bufnr].eol or (vim.bo[bufnr].fixeol and not vim.bo[bufnr].binary))
fix_eol = fix_eol and get_line(bufnr, max - 1) == ''
if fix_eol then
api.nvim_buf_set_lines(bufnr, -2, -1, false, {})
@ -1076,7 +1072,7 @@ function M.make_floating_popup_options(width, height, opts)
local wincol = opts.relative == 'mouse' and vim.fn.getmousepos().column or vim.fn.wincol()
if wincol + width + (opts.offset_x or 0) <= api.nvim_get_option('columns') then
if wincol + width + (opts.offset_x or 0) <= vim.o.columns then
anchor = anchor .. 'W'
col = 0
else
@ -1142,7 +1138,7 @@ function M.show_document(location, offset_encoding, opts)
or focus and api.nvim_get_current_win()
or create_window_without_focus()
api.nvim_buf_set_option(bufnr, 'buflisted', true)
vim.bo[bufnr].buflisted = true
api.nvim_win_set_buf(win, bufnr)
if focus then
api.nvim_set_current_win(win)
@ -1201,12 +1197,12 @@ function M.preview_location(location, opts)
end
local range = location.targetRange or location.range
local contents = api.nvim_buf_get_lines(bufnr, range.start.line, range['end'].line + 1, false)
local syntax = api.nvim_buf_get_option(bufnr, 'syntax')
local syntax = vim.bo[bufnr].syntax
if syntax == '' then
-- When no syntax is set, we use filetype as fallback. This might not result
-- in a valid syntax definition. See also ft detection in stylize_markdown.
-- An empty syntax is more common now with TreeSitter, since TS disables syntax.
syntax = api.nvim_buf_get_option(bufnr, 'filetype')
syntax = vim.bo[bufnr].filetype
end
opts = opts or {}
opts.focus_id = 'location'
@ -1665,7 +1661,7 @@ function M.open_floating_preview(contents, syntax, opts)
contents = M.stylize_markdown(floating_bufnr, contents, opts)
else
if syntax then
api.nvim_buf_set_option(floating_bufnr, 'syntax', syntax)
vim.bo[floating_bufnr].syntax = syntax
end
api.nvim_buf_set_lines(floating_bufnr, 0, -1, true, contents)
end
@ -1681,16 +1677,16 @@ function M.open_floating_preview(contents, syntax, opts)
local float_option = M.make_floating_popup_options(width, height, opts)
local floating_winnr = api.nvim_open_win(floating_bufnr, false, float_option)
if do_stylize then
api.nvim_win_set_option(floating_winnr, 'conceallevel', 2)
api.nvim_win_set_option(floating_winnr, 'concealcursor', 'n')
vim.wo[floating_winnr].conceallevel = 2
vim.wo[floating_winnr].concealcursor = 'n'
end
-- disable folding
api.nvim_win_set_option(floating_winnr, 'foldenable', false)
vim.wo[floating_winnr].foldenable = false
-- soft wrapping
api.nvim_win_set_option(floating_winnr, 'wrap', opts.wrap)
vim.wo[floating_winnr].wrap = opts.wrap
api.nvim_buf_set_option(floating_bufnr, 'modifiable', false)
api.nvim_buf_set_option(floating_bufnr, 'bufhidden', 'wipe')
vim.bo[floating_bufnr].modifiable = false
vim.bo[floating_bufnr].bufhidden = 'wipe'
api.nvim_buf_set_keymap(
floating_bufnr,
'n',

View File

@ -1328,11 +1328,11 @@ function! s:OpenHoverPreview(lines, filetype) abort
\ })
if a:filetype isnot v:null
call nvim_win_set_option(float_win_id, 'filetype', a:filetype)
call nvim_set_option_value('filetype', a:filetype, { 'win' : float_win_id })
endif
call nvim_buf_set_option(buf, 'modified', v:false)
call nvim_buf_set_option(buf, 'modifiable', v:false)
call nvim_set_option_value('modified', v:false, { 'buf' : buf })
call nvim_set_option_value('modifiable', v:false, { 'buf' : buf })
" Unlike preview window, :pclose does not close window. Instead, close
" hover window automatically when cursor is moved.

View File

@ -8,6 +8,7 @@
#include "nvim/api/buffer.h"
#include "nvim/api/deprecated.h"
#include "nvim/api/extmark.h"
#include "nvim/api/options.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/validate.h"
@ -522,3 +523,222 @@ Dictionary nvim_get_option_info(String name, Error *err)
{
return get_vimoption(name, OPT_GLOBAL, curbuf, curwin, err);
}
/// Sets the global value of an option.
///
/// @deprecated
/// @param channel_id
/// @param name Option name
/// @param value New option value
/// @param[out] err Error details, if any
void nvim_set_option(uint64_t channel_id, String name, Object value, Error *err)
FUNC_API_SINCE(1)
{
set_option_to(channel_id, NULL, SREQ_GLOBAL, name, value, err);
}
/// Gets the global value of an option.
///
/// @deprecated
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option value (global)
Object nvim_get_option(String name, Arena *arena, Error *err)
FUNC_API_SINCE(1)
{
return get_option_from(NULL, SREQ_GLOBAL, name, err);
}
/// Gets a buffer option value
///
/// @deprecated
/// @param buffer Buffer handle, or 0 for current buffer
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option value
Object nvim_buf_get_option(Buffer buffer, String name, Arena *arena, Error *err)
FUNC_API_SINCE(1)
{
buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) {
return (Object)OBJECT_INIT;
}
return get_option_from(buf, SREQ_BUF, name, err);
}
/// Sets a buffer option value. Passing `nil` as value deletes the option (only
/// works if there's a global fallback)
///
/// @deprecated
/// @param channel_id
/// @param buffer Buffer handle, or 0 for current buffer
/// @param name Option name
/// @param value Option value
/// @param[out] err Error details, if any
void nvim_buf_set_option(uint64_t channel_id, Buffer buffer, String name, Object value, Error *err)
FUNC_API_SINCE(1)
{
buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) {
return;
}
set_option_to(channel_id, buf, SREQ_BUF, name, value, err);
}
/// Gets a window option value
///
/// @deprecated
/// @param window Window handle, or 0 for current window
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option value
Object nvim_win_get_option(Window window, String name, Arena *arena, Error *err)
FUNC_API_SINCE(1)
{
win_T *win = find_window_by_handle(window, err);
if (!win) {
return (Object)OBJECT_INIT;
}
return get_option_from(win, SREQ_WIN, name, err);
}
/// Sets a window option value. Passing `nil` as value deletes the option (only
/// works if there's a global fallback)
///
/// @deprecated
/// @param channel_id
/// @param window Window handle, or 0 for current window
/// @param name Option name
/// @param value Option value
/// @param[out] err Error details, if any
void nvim_win_set_option(uint64_t channel_id, Window window, String name, Object value, Error *err)
FUNC_API_SINCE(1)
{
win_T *win = find_window_by_handle(window, err);
if (!win) {
return;
}
set_option_to(channel_id, win, SREQ_WIN, name, value, err);
}
/// Gets the value of a global or local (buffer, window) option.
///
/// @param from If `type` is `SREQ_WIN` or `SREQ_BUF`, this must be a pointer
/// to the window or buffer.
/// @param type One of `SREQ_GLOBAL`, `SREQ_WIN` or `SREQ_BUF`
/// @param name The option name
/// @param[out] err Details of an error that may have occurred
/// @return the option value
static Object get_option_from(void *from, int type, String name, Error *err)
{
Object rv = OBJECT_INIT;
VALIDATE_S(name.size > 0, "option name", "<empty>", {
return rv;
});
// Return values
int64_t numval;
char *stringval = NULL;
int flags = get_option_value_strict(name.data, &numval, &stringval, type, from);
VALIDATE_S(flags != 0, "option name", name.data, {
return rv;
});
if (flags & SOPT_BOOL) {
rv.type = kObjectTypeBoolean;
rv.data.boolean = numval ? true : false;
} else if (flags & SOPT_NUM) {
rv.type = kObjectTypeInteger;
rv.data.integer = numval;
} else if (flags & SOPT_STRING) {
if (!stringval) {
api_set_error(err, kErrorTypeException, "Failed to get option '%s'", name.data);
return rv;
}
rv.type = kObjectTypeString;
rv.data.string.data = stringval;
rv.data.string.size = strlen(stringval);
} else {
api_set_error(err, kErrorTypeException, "Unknown type for option '%s'", name.data);
}
return rv;
}
/// Sets the value of a global or local (buffer, window) option.
///
/// @param to If `type` is `SREQ_WIN` or `SREQ_BUF`, this must be a pointer
/// to the window or buffer.
/// @param type One of `SREQ_GLOBAL`, `SREQ_WIN` or `SREQ_BUF`
/// @param name The option name
/// @param[out] err Details of an error that may have occurred
static void set_option_to(uint64_t channel_id, void *to, int type, String name, Object value,
Error *err)
{
VALIDATE_S(name.size > 0, "option name", "<empty>", {
return;
});
int flags = get_option_value_strict(name.data, NULL, NULL, type, to);
VALIDATE_S(flags != 0, "option name", name.data, {
return;
});
if (value.type == kObjectTypeNil) {
if (type == SREQ_GLOBAL) {
api_set_error(err, kErrorTypeException, "Cannot unset option '%s'", name.data);
return;
} else if (!(flags & SOPT_GLOBAL)) {
api_set_error(err, kErrorTypeException,
"Cannot unset option '%s' because it doesn't have a global value",
name.data);
return;
} else {
unset_global_local_option(name.data, to);
return;
}
}
long numval = 0;
char *stringval = NULL;
if (flags & SOPT_BOOL) {
VALIDATE(value.type == kObjectTypeBoolean, "Option '%s' value must be Boolean", name.data, {
return;
});
numval = value.data.boolean;
} else if (flags & SOPT_NUM) {
VALIDATE(value.type == kObjectTypeInteger, "Option '%s' value must be Integer", name.data, {
return;
});
VALIDATE((value.data.integer <= INT_MAX && value.data.integer >= INT_MIN),
"Option '%s' value is out of range", name.data, {
return;
});
numval = (int)value.data.integer;
} else {
VALIDATE(value.type == kObjectTypeString, "Option '%s' value must be String", name.data, {
return;
});
stringval = value.data.string.data;
}
// For global-win-local options -> setlocal
// For win-local options -> setglobal and setlocal (opt_flags == 0)
const int opt_flags = (type == SREQ_WIN && !(flags & SOPT_GLOBAL)) ? 0 :
(type == SREQ_GLOBAL) ? OPT_GLOBAL : OPT_LOCAL;
WITH_SCRIPT_CONTEXT(channel_id, {
access_option_value_for(name.data, &numval, &stringval, opt_flags, type, to, false, err);
});
}

View File

@ -341,218 +341,6 @@ Dictionary nvim_get_option_info2(String name, Dict(option) *opts, Error *err)
return get_vimoption(name, scope, buf, win, err);
}
/// Sets the global value of an option.
///
/// @param channel_id
/// @param name Option name
/// @param value New option value
/// @param[out] err Error details, if any
void nvim_set_option(uint64_t channel_id, String name, Object value, Error *err)
FUNC_API_SINCE(1)
{
set_option_to(channel_id, NULL, SREQ_GLOBAL, name, value, err);
}
/// Gets the global value of an option.
///
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option value (global)
Object nvim_get_option(String name, Arena *arena, Error *err)
FUNC_API_SINCE(1)
{
return get_option_from(NULL, SREQ_GLOBAL, name, err);
}
/// Gets a buffer option value
///
/// @param buffer Buffer handle, or 0 for current buffer
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option value
Object nvim_buf_get_option(Buffer buffer, String name, Arena *arena, Error *err)
FUNC_API_SINCE(1)
{
buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) {
return (Object)OBJECT_INIT;
}
return get_option_from(buf, SREQ_BUF, name, err);
}
/// Sets a buffer option value. Passing `nil` as value deletes the option (only
/// works if there's a global fallback)
///
/// @param channel_id
/// @param buffer Buffer handle, or 0 for current buffer
/// @param name Option name
/// @param value Option value
/// @param[out] err Error details, if any
void nvim_buf_set_option(uint64_t channel_id, Buffer buffer, String name, Object value, Error *err)
FUNC_API_SINCE(1)
{
buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) {
return;
}
set_option_to(channel_id, buf, SREQ_BUF, name, value, err);
}
/// Gets a window option value
///
/// @param window Window handle, or 0 for current window
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option value
Object nvim_win_get_option(Window window, String name, Arena *arena, Error *err)
FUNC_API_SINCE(1)
{
win_T *win = find_window_by_handle(window, err);
if (!win) {
return (Object)OBJECT_INIT;
}
return get_option_from(win, SREQ_WIN, name, err);
}
/// Sets a window option value. Passing `nil` as value deletes the option (only
/// works if there's a global fallback)
///
/// @param channel_id
/// @param window Window handle, or 0 for current window
/// @param name Option name
/// @param value Option value
/// @param[out] err Error details, if any
void nvim_win_set_option(uint64_t channel_id, Window window, String name, Object value, Error *err)
FUNC_API_SINCE(1)
{
win_T *win = find_window_by_handle(window, err);
if (!win) {
return;
}
set_option_to(channel_id, win, SREQ_WIN, name, value, err);
}
/// Gets the value of a global or local (buffer, window) option.
///
/// @param from If `type` is `SREQ_WIN` or `SREQ_BUF`, this must be a pointer
/// to the window or buffer.
/// @param type One of `SREQ_GLOBAL`, `SREQ_WIN` or `SREQ_BUF`
/// @param name The option name
/// @param[out] err Details of an error that may have occurred
/// @return the option value
static Object get_option_from(void *from, int type, String name, Error *err)
{
Object rv = OBJECT_INIT;
VALIDATE_S(name.size > 0, "option name", "<empty>", {
return rv;
});
// Return values
int64_t numval;
char *stringval = NULL;
int flags = get_option_value_strict(name.data, &numval, &stringval, type, from);
VALIDATE_S(flags != 0, "option name", name.data, {
return rv;
});
if (flags & SOPT_BOOL) {
rv.type = kObjectTypeBoolean;
rv.data.boolean = numval ? true : false;
} else if (flags & SOPT_NUM) {
rv.type = kObjectTypeInteger;
rv.data.integer = numval;
} else if (flags & SOPT_STRING) {
if (!stringval) {
api_set_error(err, kErrorTypeException, "Failed to get option '%s'", name.data);
return rv;
}
rv.type = kObjectTypeString;
rv.data.string.data = stringval;
rv.data.string.size = strlen(stringval);
} else {
api_set_error(err, kErrorTypeException, "Unknown type for option '%s'", name.data);
}
return rv;
}
/// Sets the value of a global or local (buffer, window) option.
///
/// @param to If `type` is `SREQ_WIN` or `SREQ_BUF`, this must be a pointer
/// to the window or buffer.
/// @param type One of `SREQ_GLOBAL`, `SREQ_WIN` or `SREQ_BUF`
/// @param name The option name
/// @param[out] err Details of an error that may have occurred
void set_option_to(uint64_t channel_id, void *to, int type, String name, Object value, Error *err)
{
VALIDATE_S(name.size > 0, "option name", "<empty>", {
return;
});
int flags = get_option_value_strict(name.data, NULL, NULL, type, to);
VALIDATE_S(flags != 0, "option name", name.data, {
return;
});
if (value.type == kObjectTypeNil) {
if (type == SREQ_GLOBAL) {
api_set_error(err, kErrorTypeException, "Cannot unset option '%s'", name.data);
return;
} else if (!(flags & SOPT_GLOBAL)) {
api_set_error(err, kErrorTypeException,
"Cannot unset option '%s' because it doesn't have a global value",
name.data);
return;
} else {
unset_global_local_option(name.data, to);
return;
}
}
long numval = 0;
char *stringval = NULL;
if (flags & SOPT_BOOL) {
VALIDATE(value.type == kObjectTypeBoolean, "Option '%s' value must be Boolean", name.data, {
return;
});
numval = value.data.boolean;
} else if (flags & SOPT_NUM) {
VALIDATE(value.type == kObjectTypeInteger, "Option '%s' value must be Integer", name.data, {
return;
});
VALIDATE((value.data.integer <= INT_MAX && value.data.integer >= INT_MIN),
"Option '%s' value is out of range", name.data, {
return;
});
numval = (int)value.data.integer;
} else {
VALIDATE(value.type == kObjectTypeString, "Option '%s' value must be String", name.data, {
return;
});
stringval = value.data.string.data;
}
// For global-win-local options -> setlocal
// For win-local options -> setglobal and setlocal (opt_flags == 0)
const int opt_flags = (type == SREQ_WIN && !(flags & SOPT_GLOBAL)) ? 0 :
(type == SREQ_GLOBAL) ? OPT_GLOBAL : OPT_LOCAL;
WITH_SCRIPT_CONTEXT(channel_id, {
access_option_value_for(name.data, &numval, &stringval, opt_flags, type, to, false, err);
});
}
static getoption_T access_option_value(char *key, long *numval, char **stringval, int opt_flags,
bool get, Error *err)
{
@ -571,8 +359,8 @@ static getoption_T access_option_value(char *key, long *numval, char **stringval
}
}
static getoption_T access_option_value_for(char *key, long *numval, char **stringval, int opt_flags,
int opt_type, void *from, bool get, Error *err)
getoption_T access_option_value_for(char *key, long *numval, char **stringval, int opt_flags,
int opt_type, void *from, bool get, Error *err)
{
bool need_switch = false;
switchwin_T switchwin;

View File

@ -3,6 +3,7 @@
#include "nvim/api/keysets.h"
#include "nvim/api/private/defs.h"
#include "nvim/option.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/options.h.generated.h"

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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,

View File

@ -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())

View File

@ -141,7 +141,7 @@ describe('autocmd', function()
describe('BufLeave autocommand', function()
it('can wipe out the buffer created by :edit which triggered autocmd',
function()
meths.set_option('hidden', true)
meths.set_option_value('hidden', true, {})
curbufmeths.set_lines(0, 1, false, {
'start of test file xx',
'end of test file xx'})

View File

@ -26,7 +26,7 @@ describe('CursorHold', function()
-- if testing with small 'updatetime' fails, double its value and test again
retry(10, nil, function()
ut = ut * 2
meths.set_option('updatetime', ut)
meths.set_option_value('updatetime', ut, {})
feed('0') -- reset did_cursorhold
meths.set_var('cursorhold', 0)
sleep(ut / 4)
@ -51,12 +51,12 @@ describe('CursorHold', function()
end)
it("reducing 'updatetime' while waiting for CursorHold #20241", function()
meths.set_option('updatetime', 10000)
meths.set_option_value('updatetime', 10000, {})
feed('0') -- reset did_cursorhold
meths.set_var('cursorhold', 0)
sleep(50)
eq(0, meths.get_var('cursorhold'))
meths.set_option('updatetime', 20)
meths.set_option_value('updatetime', 20, {})
sleep(10)
eq(1, meths.get_var('cursorhold'))
end)

View File

@ -16,14 +16,14 @@ local is_os = helpers.is_os
describe('autocmd TermClose', function()
before_each(function()
clear()
nvim('set_option', 'shell', testprg('shell-test'))
nvim('set_option_value', 'shell', testprg('shell-test'), {})
command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=')
end)
local function test_termclose_delete_own_buf()
-- The terminal process needs to keep running so that TermClose isn't triggered immediately.
nvim('set_option', 'shell', string.format('"%s" INTERACT', testprg('shell-test')))
nvim('set_option_value', 'shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
command('autocmd TermClose * bdelete!')
command('terminal')
matches('^TermClose Autocommands for "%*": Vim%(bdelete%):E937: Attempt to delete a buffer that is in use: term://',
@ -51,7 +51,7 @@ describe('autocmd TermClose', function()
it('triggers when long-running terminal job gets stopped', function()
skip(is_os('win'))
nvim('set_option', 'shell', is_os('win') and 'cmd.exe' or 'sh')
nvim('set_option_value', 'shell', is_os('win') and 'cmd.exe' or 'sh', {})
command('autocmd TermClose * let g:test_termclose = 23')
command('terminal')
command('call jobstop(b:terminal_job_id)')
@ -60,8 +60,8 @@ describe('autocmd TermClose', function()
it('kills job trapping SIGTERM', function()
skip(is_os('win'))
nvim('set_option', 'shell', 'sh')
nvim('set_option', 'shellcmdflag', '-c')
nvim('set_option_value', 'shell', 'sh', {})
nvim('set_option_value', 'shellcmdflag', '-c', {})
command([[ let g:test_job = jobstart('trap "" TERM && echo 1 && sleep 60', { ]]
.. [[ 'on_stdout': {-> execute('let g:test_job_started = 1')}, ]]
.. [[ 'on_exit': {-> execute('let g:test_job_exited = 1')}}) ]])
@ -80,8 +80,8 @@ describe('autocmd TermClose', function()
it('kills PTY job trapping SIGHUP and SIGTERM', function()
skip(is_os('win'))
nvim('set_option', 'shell', 'sh')
nvim('set_option', 'shellcmdflag', '-c')
nvim('set_option_value', 'shell', 'sh', {})
nvim('set_option_value', 'shellcmdflag', '-c', {})
command([[ let g:test_job = jobstart('trap "" HUP TERM && echo 1 && sleep 60', { ]]
.. [[ 'pty': 1,]]
.. [[ 'on_stdout': {-> execute('let g:test_job_started = 1')}, ]]

View File

@ -24,7 +24,7 @@ describe('spellfile', function()
-- │ ┌ Spell file version (#VIMSPELLVERSION)
local spellheader = 'VIMspell\050'
it('errors out when prefcond section is truncated', function()
meths.set_option('runtimepath', testdir)
meths.set_option_value('runtimepath', testdir, {})
write_file(testdir .. '/spell/en.ascii.spl',
-- ┌ Section identifier (#SN_PREFCOND)
-- │ ┌ Section flags (#SNF_REQUIRED or zero)
@ -34,12 +34,12 @@ describe('spellfile', function()
-- │ ┌ Condition length (1 byte)
-- │ │ ┌ Condition regex (missing!)
.. '\000\001\001')
meths.set_option('spelllang', 'en')
meths.set_option_value('spelllang', 'en', {})
eq('Vim(set):E758: Truncated spell file',
exc_exec('set spell'))
end)
it('errors out when prefcond regexp contains NUL byte', function()
meths.set_option('runtimepath', testdir)
meths.set_option_value('runtimepath', testdir, {})
write_file(testdir .. '/spell/en.ascii.spl',
-- ┌ Section identifier (#SN_PREFCOND)
-- │ ┌ Section flags (#SNF_REQUIRED or zero)
@ -54,12 +54,12 @@ describe('spellfile', function()
-- │ ┌ KWORDTREE tree length (4 bytes)
-- │ │ ┌ PREFIXTREE tree length
.. '\000\000\000\000\000\000\000\000\000\000\000\000')
meths.set_option('spelllang', 'en')
meths.set_option_value('spelllang', 'en', {})
eq('Vim(set):E759: Format error in spell file',
exc_exec('set spell'))
end)
it('errors out when region contains NUL byte', function()
meths.set_option('runtimepath', testdir)
meths.set_option_value('runtimepath', testdir, {})
write_file(testdir .. '/spell/en.ascii.spl',
-- ┌ Section identifier (#SN_REGION)
-- │ ┌ Section flags (#SNF_REQUIRED or zero)
@ -71,12 +71,12 @@ describe('spellfile', function()
-- │ ┌ KWORDTREE tree length (4 bytes)
-- │ │ ┌ PREFIXTREE tree length
.. '\000\000\000\000\000\000\000\000\000\000\000\000')
meths.set_option('spelllang', 'en')
meths.set_option_value('spelllang', 'en', {})
eq('Vim(set):E759: Format error in spell file',
exc_exec('set spell'))
end)
it('errors out when SAL section contains NUL byte', function()
meths.set_option('runtimepath', testdir)
meths.set_option_value('runtimepath', testdir, {})
write_file(testdir .. '/spell/en.ascii.spl',
-- ┌ Section identifier (#SN_SAL)
-- │ ┌ Section flags (#SNF_REQUIRED or zero)
@ -95,15 +95,15 @@ describe('spellfile', function()
-- │ ┌ KWORDTREE tree length (4 bytes)
-- │ │ ┌ PREFIXTREE tree length
.. '\000\000\000\000\000\000\000\000\000\000\000\000')
meths.set_option('spelllang', 'en')
meths.set_option_value('spelllang', 'en', {})
eq('Vim(set):E759: Format error in spell file',
exc_exec('set spell'))
end)
it('errors out when spell header contains NUL bytes', function()
meths.set_option('runtimepath', testdir)
meths.set_option_value('runtimepath', testdir, {})
write_file(testdir .. '/spell/en.ascii.spl',
spellheader:sub(1, -3) .. '\000\000')
meths.set_option('spelllang', 'en')
meths.set_option_value('spelllang', 'en', {})
eq('Vim(set):E757: This does not look like a spell file',
exc_exec('set spell'))
end)

View File

@ -40,9 +40,9 @@ end)
describe('startup', function()
it('--clean', function()
clear()
ok(string.find(alter_slashes(meths.get_option('runtimepath')), funcs.stdpath('config'), 1, true) ~= nil)
ok(string.find(alter_slashes(meths.get_option_value('runtimepath', {})), funcs.stdpath('config'), 1, true) ~= nil)
clear('--clean')
ok(string.find(alter_slashes(meths.get_option('runtimepath')), funcs.stdpath('config'), 1, true) == nil)
ok(string.find(alter_slashes(meths.get_option_value('runtimepath', {})), funcs.stdpath('config'), 1, true) == nil)
end)
it('--startuptime', function()
@ -589,7 +589,7 @@ describe('startup', function()
]]
eq({'ordinary', 'FANCY', 'mittel', 'FANCY after', 'ordinary after'}, exec_lua [[ return _G.test_loadorder ]])
local rtp = meths.get_option'rtp'
local rtp = meths.get_option_value('rtp', {})
ok(startswith(rtp, 'test/functional/fixtures/nvim,test/functional/fixtures/pack/*/start/*,test/functional/fixtures/start/*,test/functional/fixtures,test/functional/fixtures/middle,'),
'startswith(…)', 'rtp='..rtp)
end)

View File

@ -59,7 +59,7 @@ describe('K', function()
end)
it('empty string falls back to :help #19298', function()
meths.set_option('keywordprg', '')
meths.set_option_value('keywordprg', '', {})
meths.buf_set_lines(0, 0, -1, true, {'doesnotexist'})
feed('K')
eq('E149: Sorry, no help for doesnotexist', meths.get_vvar('errmsg'))

View File

@ -988,7 +988,7 @@ describe('completion', function()
return ''
endfunction
]])
meths.set_option('completeopt', 'menuone,noselect')
meths.set_option_value('completeopt', 'menuone,noselect', {})
meths.set_var('_complist', {{
word=0,
abbr=1,

View File

@ -55,7 +55,7 @@ describe('cmdline', function()
it('correctly clears end of the history', function()
-- Regression test: check absence of the memory leak when clearing end of
-- the history using ex_getln.c/clr_history().
meths.set_option('history', 1)
meths.set_option_value('history', 1, {})
eq(1, funcs.histadd(':', 'foo'))
eq(1, funcs.histdel(':'))
eq('', funcs.histget(':', -1))

View File

@ -8,6 +8,7 @@ local clear = helpers.clear
local funcs = helpers.funcs
local command = helpers.command
local curbufmeths = helpers.curbufmeths
local meths = helpers.meths
local Screen = require('test.functional.ui.screen')
local cmdtest = function(cmd, prep, ret1)
@ -42,7 +43,7 @@ local cmdtest = function(cmd, prep, ret1)
eq(hisline, funcs.histget(':', -2))
eq(cmd, funcs.histget(':'))
-- Test that command-line window was launched
eq('nofile', curbufmeths.get_option('buftype'))
eq('nofile', meths.get_option_value('buftype', {buf=0}))
eq('n', funcs.mode(1))
feed('<CR>')
eq('c', funcs.mode(1))

View File

@ -14,7 +14,7 @@ describe(':ls', function()
end)
it('R, F for :terminal buffers', function()
nvim('set_option', 'shell', string.format('"%s" INTERACT', testprg('shell-test')))
nvim('set_option_value', 'shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
command('edit foo')
command('set hidden')

View File

@ -22,14 +22,14 @@ describe(':make', function()
end)
it('captures stderr & non zero exit code #14349', function ()
nvim('set_option', 'makeprg', testprg('shell-test')..' foo')
nvim('set_option_value', 'makeprg', testprg('shell-test')..' foo', {})
local out = eval('execute("make")')
-- Error message is captured in the file and printed in the footer
matches('[\r\n]+.*[\r\n]+Unknown first argument%: foo[\r\n]+%(1 of 1%)%: Unknown first argument%: foo', out)
end)
it('captures stderr & zero exit code #14349', function ()
nvim('set_option', 'makeprg', testprg('shell-test'))
nvim('set_option_value', 'makeprg', testprg('shell-test'), {})
local out = eval('execute("make")')
-- Ensure there are no "shell returned X" messages between
-- command and last line (indicating zero exit)

View File

@ -18,7 +18,7 @@ describe(':*map', function()
it('are not affected by &isident', function()
meths.set_var('counter', 0)
command('nnoremap <C-x> :let counter+=1<CR>')
meths.set_option('isident', ('%u'):format(('>'):byte()))
meths.set_option_value('isident', ('%u'):format(('>'):byte()), {})
command('nnoremap <C-y> :let counter+=1<CR>')
-- &isident used to disable keycode parsing here as well
feed('\24\25<C-x><C-y>')

View File

@ -81,13 +81,13 @@ describe(':mksession', function()
local buf_count = #meths.list_bufs()
eq(2, buf_count)
eq('terminal', meths.buf_get_option(0, 'buftype'))
eq('terminal', meths.get_option_value('buftype', { buf = 0 }))
test_terminal_session_disabled(2)
-- no terminal should be set. As a side effect we end up with a blank buffer
eq('', meths.buf_get_option(meths.list_bufs()[1], 'buftype'))
eq('', meths.buf_get_option(meths.list_bufs()[2], 'buftype'))
eq('', meths.get_option_value('buftype', { buf = meths.list_bufs()[1] }))
eq('', meths.get_option_value('buftype', { buf = meths.list_bufs()[2] }))
end
)
@ -112,7 +112,7 @@ describe(':mksession', function()
it('do not restore :terminal if not set in sessionoptions, only buffer #13078', function()
command('terminal')
eq('terminal', meths.buf_get_option(0, 'buftype'))
eq('terminal', meths.get_option_value('buftype', { buf = 0 }))
local buf_count = #meths.list_bufs()
eq(1, buf_count)
@ -120,7 +120,7 @@ describe(':mksession', function()
test_terminal_session_disabled(1)
-- no terminal should be set
eq('', meths.buf_get_option(0, 'buftype'))
eq('', meths.get_option_value('buftype', { buf = 0 }))
end)
it('restores tab-local working directories', function()
@ -249,7 +249,7 @@ describe(':mksession', function()
style = 'minimal',
}
meths.open_win(buf, false, config)
local cmdheight = meths.get_option('cmdheight')
local cmdheight = meths.get_option_value('cmdheight', {})
command('mksession ' .. session_file)
-- Create a new test instance of Nvim.
@ -262,7 +262,7 @@ describe(':mksession', function()
-- window was not restored.
eq(1, funcs.winnr('$'))
-- The command-line height should remain the same as it was.
eq(cmdheight, meths.get_option('cmdheight'))
eq(cmdheight, meths.get_option_value('cmdheight', {}))
os.remove(tmpfile)
end)

View File

@ -48,7 +48,7 @@ describe(':source', function()
pending("'shellslash' only works on Windows")
return
end
meths.set_option('shellslash', false)
meths.set_option_value('shellslash', false, {})
mkdir('Xshellslash')
write_file([[Xshellslash/Xstack.vim]], [[

View File

@ -18,7 +18,7 @@ local function last_set_tests(cmd)
script_location = table.concat{current_dir, helpers.get_pathsep(), script_file}
write_file(script_file, [[
vim.api.nvim_set_option('hlsearch', false)
vim.api.nvim_set_option_value('hlsearch', false, {})
vim.bo.expandtab = true
vim.opt.number = true
vim.api.nvim_set_keymap('n', '<leader>key1', ':echo "test"<cr>', {noremap = true})
@ -160,7 +160,7 @@ describe('lua verbose:', function()
clear()
script_file = 'test_luafile.lua'
write_file(script_file, [[
vim.api.nvim_set_option('hlsearch', false)
vim.api.nvim_set_option_value('hlsearch', false, {})
]])
exec(':source '..script_file)
end)

View File

@ -129,18 +129,18 @@ describe(':write', function()
eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'),
pcall_err(command, 'write .'))
end
meths.set_option('writeany', true)
meths.set_option_value('writeany', true, {})
-- Message from buf_write
eq(('Vim(write):E502: "." is a directory'), pcall_err(command, 'write .'))
funcs.mkdir(fname_bak)
meths.set_option('backupdir', '.')
meths.set_option('backup', true)
meths.set_option_value('backupdir', '.', {})
meths.set_option_value('backup', true, {})
write_file(fname, 'content0')
command('edit ' .. fname)
funcs.setline(1, 'TTY')
eq('Vim(write):E510: Can\'t make backup file (add ! to override)',
pcall_err(command, 'write'))
meths.set_option('backup', false)
meths.set_option_value('backup', false, {})
funcs.setfperm(fname, 'r--------')
eq('Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)',
pcall_err(command, 'write'))

View File

@ -15,7 +15,6 @@ local clear = helpers.clear
local insert = helpers.insert
local command = helpers.command
local write_file = helpers.write_file
local curbufmeths = helpers.curbufmeths
local expect_exit = helpers.expect_exit
local mkdir = helpers.mkdir
@ -58,9 +57,9 @@ describe("'directory' option", function()
line 3 Abcdefghij
end of testfile]])
meths.set_option('swapfile', true)
curbufmeths.set_option('swapfile', true)
meths.set_option('directory', '.')
meths.set_option_value('swapfile', true, {})
meths.set_option_value('swapfile', true, {buf=0})
meths.set_option_value('directory', '.', {})
-- sanity check: files should not exist yet.
eq(nil, luv.fs_stat('.Xtest1.swp'))
@ -72,7 +71,7 @@ describe("'directory' option", function()
-- reading the output from :!ls.
neq(nil, luv.fs_stat('.Xtest1.swp'))
meths.set_option('directory', './Xtest2,.')
meths.set_option_value('directory', './Xtest2,.', {})
command('edit Xtest1')
poke_eventloop()
@ -81,10 +80,10 @@ describe("'directory' option", function()
eq({ "Xtest1.swp", "Xtest3" }, ls_dir_sorted("Xtest2"))
meths.set_option('directory', 'Xtest.je')
meths.set_option_value('directory', 'Xtest.je', {})
command('bdelete')
command('edit Xtest2/Xtest3')
eq(true, curbufmeths.get_option('swapfile'))
eq(true, meths.get_option_value('swapfile', {buf=0}))
poke_eventloop()
eq({ "Xtest3" }, ls_dir_sorted("Xtest2"))

View File

@ -631,24 +631,24 @@ describe('au OptionSet', function()
it('should trigger if a boolean option be set globally', function()
set_hook('autochdir')
nvim.set_option('autochdir', true)
eq(true, nvim.get_option('autochdir'))
nvim.set_option_value('autochdir', true, {scope='global'})
eq(true, nvim.get_option_value('autochdir', {scope='global'}))
expected_combination({'autochdir', 0, '', 0, 1, 'global', 'setglobal'})
end)
it('should trigger if a number option be set globally', function()
set_hook('cmdheight')
nvim.set_option('cmdheight', 5)
eq(5, nvim.get_option('cmdheight'))
nvim.set_option_value('cmdheight', 5, {scope='global'})
eq(5, nvim.get_option_value('cmdheight', {scope='global'}))
expected_combination({'cmdheight', 1, '', 1, 5, 'global', 'setglobal'})
end)
it('should trigger if a string option be set globally', function()
set_hook('ambiwidth')
nvim.set_option('ambiwidth', 'double')
eq('double', nvim.get_option('ambiwidth'))
nvim.set_option_value('ambiwidth', 'double', {scope='global'})
eq('double', nvim.get_option_value('ambiwidth', {scope='global'}))
expected_combination({'ambiwidth', 'single', '', 'single', 'double', 'global', 'setglobal'})
end)
end)

View File

@ -10,7 +10,7 @@ describe('buffer', function()
before_each(function()
clear()
meths.ui_attach(80, 24, {})
meths.set_option('hidden', false)
meths.set_option_value('hidden', false, {})
end)
it('deleting a modified buffer with :confirm', function()

View File

@ -225,9 +225,9 @@ describe('cmdline', function()
[3] = {reverse = true}, -- TabLineFill
})
screen:attach()
meths.set_option('laststatus', 2)
meths.set_option('showtabline', 2)
meths.set_option('cmdheight', 1)
meths.set_option_value('laststatus', 2, {})
meths.set_option_value('showtabline', 2, {})
meths.set_option_value('cmdheight', 1, {})
screen:expect([[
{2: [No Name] }{3: }|
^ |
@ -247,10 +247,10 @@ describe('cmdline', function()
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
}
screen:attach()
meths.set_option('ruler', true)
meths.set_option('rulerformat', 'longish')
meths.set_option('laststatus', 0)
meths.set_option('winwidth', 1)
meths.set_option_value('ruler', true, {})
meths.set_option_value('rulerformat', 'longish', {})
meths.set_option_value('laststatus', 0, {})
meths.set_option_value('winwidth', 1, {})
feed [[<C-W>v<C-W>|<C-W>p]]
screen:expect [[
^ |

View File

@ -12,8 +12,8 @@ describe('file changed dialog', function()
before_each(function()
clear()
meths.ui_attach(80, 24, {})
meths.set_option('autoread', false)
meths.set_option('fsync', true)
meths.set_option_value('autoread', false, {})
meths.set_option_value('fsync', true, {})
end)
it('works', function()

View File

@ -361,9 +361,9 @@ describe('messages', function()
screen:attach()
command('cd '..nvim_dir)
meths.set_option('shell', './shell-test')
meths.set_option('shellcmdflag', 'REP 20')
meths.set_option('shellxquote', '') -- win: avoid extra quotes
meths.set_option_value('shell', './shell-test', {})
meths.set_option_value('shellcmdflag', 'REP 20', {})
meths.set_option_value('shellxquote', '', {}) -- win: avoid extra quotes
-- display a page and go back, results in exactly the same view
feed([[:4 verbose echo system('foo')<CR>]])

View File

@ -12,7 +12,7 @@ describe('Vim script', function()
it('Error when if/for/while/try/function is nested too deep',function()
local screen = Screen.new(80, 24)
screen:attach()
meths.set_option('laststatus', 2)
meths.set_option_value('laststatus', 2, {})
exec([[
" Deep nesting of if ... endif
func Test1()

View File

@ -415,7 +415,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('opening lines', function()
local check_events = setup_eventcheck(verify, origlines)
-- meths.buf_set_option(0, 'autoindent', true)
-- meths.set_option_value('autoindent', true, { buf = 0 })
feed 'Go'
check_events {
{ "test1", "bytes", 1, 4, 7, 0, 114, 0, 0, 0, 1, 0, 1 };
@ -428,7 +428,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('opening lines with autoindent', function()
local check_events = setup_eventcheck(verify, origlines)
meths.buf_set_option(0, 'autoindent', true)
meths.set_option_value('autoindent', true, { buf = 0 })
feed 'Go'
check_events {
{ "test1", "bytes", 1, 4, 7, 0, 114, 0, 0, 0, 1, 0, 5 };
@ -462,8 +462,8 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('continuing comments with fo=or', function()
local check_events = setup_eventcheck(verify, {'// Comment'})
meths.buf_set_option(0, 'formatoptions', 'ro')
meths.buf_set_option(0, 'filetype', 'c')
meths.set_option_value('formatoptions', 'ro', { buf = 0 })
meths.set_option_value('filetype', 'c', { buf = 0 })
feed 'A<CR>'
check_events {
{ "test1", "bytes", 1, 4, 0, 10, 10, 0, 0, 0, 1, 3, 4 };
@ -603,7 +603,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it('inccomand=nosplit and substitute', function()
local check_events = setup_eventcheck(verify,
{"abcde", "12345"})
meths.set_option('inccommand', 'nosplit')
meths.set_option_value('inccommand', 'nosplit', {})
-- linewise substitute
feed(':%s/bcd/')
@ -998,7 +998,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
it("virtual edit", function ()
local check_events = setup_eventcheck(verify, { "", " " })
meths.set_option("virtualedit", "all")
meths.set_option_value('virtualedit', "all", {})
feed [[<Right><Right>iab<ESC>]]

View File

@ -31,14 +31,12 @@ describe('nlua_expand_pat', function()
eq(
{{
'nvim_buf_set_lines',
'nvim_buf_set_option'
}, 8
},
get_completions('vim.api.nvim_buf_', {
vim = {
api = {
nvim_buf_set_lines = true,
nvim_buf_set_option = true,
nvim_win_doesnt_match = true,
},
other_key = true,
@ -68,14 +66,12 @@ describe('nlua_expand_pat', function()
eq(
{{
'nvim_buf_set_lines',
'nvim_buf_set_option'
}, 11
},
get_completions('vim["api"].nvim_buf_', {
vim = {
api = {
nvim_buf_set_lines = true,
nvim_buf_set_option = true,
nvim_win_doesnt_match = true,
},
other_key = true,
@ -88,7 +84,6 @@ describe('nlua_expand_pat', function()
eq(
{{
'nvim_buf_set_lines',
'nvim_buf_set_option'
}, 21
},
get_completions('vim["nested"]["api"].nvim_buf_', {
@ -96,7 +91,6 @@ describe('nlua_expand_pat', function()
nested = {
api = {
nvim_buf_set_lines = true,
nvim_buf_set_option = true,
nvim_win_doesnt_match = true,
},
},
@ -121,7 +115,6 @@ describe('nlua_expand_pat', function()
eq(
{{
'nvim_buf_set_lines',
'nvim_buf_set_option'
}, 12
},
get_completions('vim[MY_VAR].nvim_buf_', {
@ -129,7 +122,6 @@ describe('nlua_expand_pat', function()
vim = {
api = {
nvim_buf_set_lines = true,
nvim_buf_set_option = true,
nvim_win_doesnt_match = true,
},
other_key = true,

View File

@ -134,6 +134,6 @@ end)
describe('filetype.lua', function()
it('does not override user autocommands that set filetype #20333', function()
clear({args={'--clean', '--cmd', 'autocmd BufRead *.md set filetype=notmarkdown', 'README.md'}})
eq('notmarkdown', meths.buf_get_option(0, 'filetype'))
eq('notmarkdown', meths.get_option_value('filetype', { buf = 0 }))
end)
end)

View File

@ -18,8 +18,8 @@ describe('vim.inspect_pos', function()
vim.api.nvim_set_current_buf(buf)
vim.api.nvim_buf_set_lines(0, 0, -1, false, {"local a = 123"})
vim.api.nvim_buf_set_lines(buf1, 0, -1, false, {"--commentline"})
vim.api.nvim_buf_set_option(buf, "filetype", "lua")
vim.api.nvim_buf_set_option(buf1, "filetype", "lua")
vim.bo[buf].filetype = 'lua'
vim.bo[buf1].filetype = 'lua'
vim.api.nvim_buf_set_extmark(buf, ns1, 0, 10, { hl_group = "Normal" })
vim.api.nvim_buf_set_extmark(buf, ns2, 0, 10, { hl_group = "Normal" })
vim.cmd("syntax on")
@ -97,7 +97,7 @@ describe('vim.show_pos', function()
local buf = vim.api.nvim_create_buf(true, false)
vim.api.nvim_set_current_buf(buf)
vim.api.nvim_buf_set_lines(0, 0, -1, false, {"local a = 123"})
vim.api.nvim_buf_set_option(buf, "filetype", "lua")
vim.bo[buf].filetype = 'lua'
vim.cmd("syntax on")
return {buf, vim.show_pos(0, 0, 10)}
]])

View File

@ -514,7 +514,7 @@ describe('v:lua', function()
[5] = {bold = true, foreground = Screen.colors.SeaGreen4},
})
screen:attach()
meths.buf_set_option(0, 'omnifunc', 'v:lua.mymod.omni')
meths.set_option_value('omnifunc', 'v:lua.mymod.omni', { buf = 0 })
feed('isome st<c-x><c-o>')
screen:expect{grid=[[
some stuff^ |
@ -526,7 +526,7 @@ describe('v:lua', function()
{1:~ }|
{4:-- Omni completion (^O^N^P) }{5:match 1 of 3} |
]]}
meths.set_option('operatorfunc', 'v:lua.mymod.noisy')
meths.set_option_value('operatorfunc', 'v:lua.mymod.noisy', {})
feed('<Esc>g@g@')
eq("hey line", meths.get_current_line())
end)

View File

@ -100,7 +100,7 @@ describe('print', function()
pcall_err(command, 'lua bad_custom_error()'))
end)
it('prints strings with NULs and NLs correctly', function()
meths.set_option('more', true)
meths.set_option_value('more', true, {})
eq('abc ^@ def\nghi^@^@^@jkl\nTEST\n\n\nT\n',
exec_capture([[lua print("abc \0 def\nghi\0\0\0jkl\nTEST\n\n\nT\n")]]))
eq('abc ^@ def\nghi^@^@^@jkl\nTEST\n\n\nT^@',

View File

@ -6,7 +6,7 @@ local clear = helpers.clear
local command = helpers.command
local pathsep = helpers.get_pathsep()
local is_os = helpers.is_os
local curbufmeths = helpers.curbufmeths
local meths = helpers.meths
local exec_lua = helpers.exec_lua
local feed_command = helpers.feed_command
local feed = helpers.feed
@ -160,7 +160,7 @@ describe('vim.secure', function()
-- Cannot write file
pcall_err(command, 'write')
eq(true, curbufmeths.get_option('readonly'))
eq(true, meths.get_option_value('readonly', {buf=0}))
end)
end)

View File

@ -1496,9 +1496,9 @@ describe('lua stdlib', function()
it('vim.bo', function()
eq('', funcs.luaeval "vim.bo.filetype")
exec_lua [[
vim.api.nvim_buf_set_option(0, "filetype", "markdown")
vim.api.nvim_set_option_value("filetype", "markdown", {buf = 0})
BUF = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_option(BUF, "modifiable", false)
vim.api.nvim_set_option_value("modifiable", false, {buf = BUF})
]]
eq(false, funcs.luaeval "vim.bo.modified")
eq('markdown', funcs.luaeval "vim.bo.filetype")
@ -1519,9 +1519,9 @@ describe('lua stdlib', function()
it('vim.wo', function()
exec_lua [[
vim.api.nvim_win_set_option(0, "cole", 2)
vim.api.nvim_set_option_value("cole", 2, {win=0})
vim.cmd "split"
vim.api.nvim_win_set_option(0, "cole", 2)
vim.api.nvim_set_option_value("cole", 2, {win=0})
]]
eq(2, funcs.luaeval "vim.wo.cole")
exec_lua [[
@ -1566,8 +1566,8 @@ describe('lua stdlib', function()
local result = exec_lua [[
local result = {}
table.insert(result, vim.api.nvim_get_option('scrolloff'))
table.insert(result, vim.api.nvim_win_get_option(0, 'scrolloff'))
table.insert(result, vim.api.nvim_get_option_value('scrolloff', {scope='global'}))
table.insert(result, vim.api.nvim_get_option_value('scrolloff', {win=0}))
return result
]]
@ -1631,20 +1631,20 @@ describe('lua stdlib', function()
local result = {}
vim.opt.makeprg = "global-local"
table.insert(result, vim.api.nvim_get_option('makeprg'))
table.insert(result, vim.api.nvim_buf_get_option(0, 'makeprg'))
table.insert(result, vim.go.makeprg)
table.insert(result, vim.api.nvim_get_option_value('makeprg', {buf=0}))
vim.opt_local.mp = "only-local"
table.insert(result, vim.api.nvim_get_option('makeprg'))
table.insert(result, vim.api.nvim_buf_get_option(0, 'makeprg'))
table.insert(result, vim.go.makeprg)
table.insert(result, vim.api.nvim_get_option_value('makeprg', {buf=0}))
vim.opt_global.makeprg = "only-global"
table.insert(result, vim.api.nvim_get_option('makeprg'))
table.insert(result, vim.api.nvim_buf_get_option(0, 'makeprg'))
table.insert(result, vim.go.makeprg)
table.insert(result, vim.api.nvim_get_option_value('makeprg', {buf=0}))
vim.opt.makeprg = "global-local"
table.insert(result, vim.api.nvim_get_option('makeprg'))
table.insert(result, vim.api.nvim_buf_get_option(0, 'makeprg'))
table.insert(result, vim.go.makeprg)
table.insert(result, vim.api.nvim_get_option_value('makeprg', {buf=0}))
return result
]]
@ -2173,7 +2173,7 @@ describe('lua stdlib', function()
it('can handle isfname ,,,', function()
local result = exec_lua [[
vim.opt.isfname = "a,b,,,c"
return { vim.opt.isfname:get(), vim.api.nvim_get_option('isfname') }
return { vim.opt.isfname:get(), vim.go.isfname }
]]
eq({{",", "a", "b", "c"}, "a,b,,,c"}, result)
@ -2183,7 +2183,7 @@ describe('lua stdlib', function()
it('can handle isfname ,^,,', function()
local result = exec_lua [[
vim.opt.isfname = "a,b,^,,c"
return { vim.opt.isfname:get(), vim.api.nvim_get_option('isfname') }
return { vim.opt.isfname:get(), vim.go.isfname }
]]
eq({{"^,", "a", "b", "c"}, "a,b,^,,c"}, result)
@ -2734,14 +2734,14 @@ describe('lua stdlib', function()
describe('vim.api.nvim_buf_call', function()
it('can access buf options', function()
local buf1 = meths.get_current_buf()
local buf1 = meths.get_current_buf().id
local buf2 = exec_lua [[
buf2 = vim.api.nvim_create_buf(false, true)
return buf2
]]
eq(false, meths.buf_get_option(buf1, 'autoindent'))
eq(false, meths.buf_get_option(buf2, 'autoindent'))
eq(false, meths.get_option_value('autoindent', {buf=buf1}))
eq(false, meths.get_option_value('autoindent', {buf=buf2}))
local val = exec_lua [[
return vim.api.nvim_buf_call(buf2, function()
@ -2750,9 +2750,9 @@ describe('lua stdlib', function()
end)
]]
eq(false, meths.buf_get_option(buf1, 'autoindent'))
eq(true, meths.buf_get_option(buf2, 'autoindent'))
eq(buf1, meths.get_current_buf())
eq(false, meths.get_option_value('autoindent', {buf=buf1}))
eq(true, meths.get_option_value('autoindent', {buf=buf2}))
eq(buf1, meths.get_current_buf().id)
eq(buf2, val)
end)
@ -2771,10 +2771,10 @@ describe('lua stdlib', function()
eq(true, exec_lua([[
local function scratch_buf_call(fn)
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_option(buf, 'cindent', true)
vim.api.nvim_set_option_value('cindent', true, {buf = buf})
return vim.api.nvim_buf_call(buf, function()
return vim.api.nvim_get_current_buf() == buf
and vim.api.nvim_buf_get_option(buf, 'cindent')
and vim.api.nvim_get_option_value('cindent', {buf = buf})
and fn()
end) and vim.api.nvim_buf_delete(buf, {}) == nil
end
@ -2811,7 +2811,7 @@ describe('lua stdlib', function()
describe('vim.api.nvim_win_call', function()
it('can access window options', function()
command('vsplit')
local win1 = meths.get_current_win()
local win1 = meths.get_current_win().id
command('wincmd w')
local win2 = exec_lua [[
win2 = vim.api.nvim_get_current_win()
@ -2819,8 +2819,8 @@ describe('lua stdlib', function()
]]
command('wincmd p')
eq('', meths.win_get_option(win1, 'winhighlight'))
eq('', meths.win_get_option(win2, 'winhighlight'))
eq('', meths.get_option_value('winhighlight', {win=win1}))
eq('', meths.get_option_value('winhighlight', {win=win2}))
local val = exec_lua [[
return vim.api.nvim_win_call(win2, function()
@ -2829,9 +2829,9 @@ describe('lua stdlib', function()
end)
]]
eq('', meths.win_get_option(win1, 'winhighlight'))
eq('Normal:Normal', meths.win_get_option(win2, 'winhighlight'))
eq(win1, meths.get_current_win())
eq('', meths.get_option_value('winhighlight', {win=win1}))
eq('Normal:Normal', meths.get_option_value('winhighlight', {win=win2}))
eq(win1, meths.get_current_win().id)
eq(win2, val)
end)

View File

@ -202,8 +202,8 @@ describe('startup defaults', function()
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('shadafile'))
eq('', meths.get_option('viminfofile'))
eq('', meths.get_option_value('shadafile', {}))
eq('', meths.get_option_value('viminfofile', {}))
-- Check that shada data (such as v:oldfiles) is saved/restored.
command('edit Xtest-foo')
command('write')
@ -227,13 +227,13 @@ describe('startup defaults', function()
args_rm={'runtimepath'},
}
-- Defaults to &runtimepath.
eq(meths.get_option('runtimepath'), meths.get_option('packpath'))
eq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {}))
-- Does not follow modifications to runtimepath.
meths.command('set runtimepath+=foo')
neq(meths.get_option('runtimepath'), meths.get_option('packpath'))
neq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {}))
meths.command('set packpath+=foo')
eq(meths.get_option('runtimepath'), meths.get_option('packpath'))
eq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {}))
end)
it('v:progpath is set to the absolute path', function()
@ -318,10 +318,10 @@ describe('XDG defaults', function()
USER=nil,
}})
eq('.', meths.get_option('backupdir'))
eq('.', meths.get_option('viewdir'))
eq('.', meths.get_option('directory'))
eq('.', meths.get_option('undodir'))
eq('.', meths.get_option_value('backupdir', {}))
eq('.', meths.get_option_value('viewdir', {}))
eq('.', meths.get_option_value('directory', {}))
eq('.', meths.get_option_value('undodir', {}))
ok((funcs.tempname()):len() > 4)
end)
end)
@ -383,7 +383,7 @@ describe('XDG defaults', function()
.. ',' .. 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('runtimepath')):gsub('\\', '/'))
):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/'))
meths.command('set runtimepath&')
meths.command('set backupdir&')
meths.command('set directory&')
@ -407,15 +407,15 @@ describe('XDG defaults', function()
.. ',' .. 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('runtimepath')):gsub('\\', '/'))
):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/'))
eq('.,' .. root_path .. ('/X'):rep(4096).. '/' .. state_dir .. '/backup//',
(meths.get_option('backupdir'):gsub('\\', '/')))
(meths.get_option_value('backupdir', {}):gsub('\\', '/')))
eq(root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/swap//',
(meths.get_option('directory')):gsub('\\', '/'))
(meths.get_option_value('directory', {})):gsub('\\', '/'))
eq(root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/undo//',
(meths.get_option('undodir')):gsub('\\', '/'))
(meths.get_option_value('undodir', {})):gsub('\\', '/'))
eq(root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/view//',
(meths.get_option('viewdir')):gsub('\\', '/'))
(meths.get_option_value('viewdir', {})):gsub('\\', '/'))
end)
end)
@ -450,7 +450,7 @@ describe('XDG defaults', function()
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/'))
meths.command('set runtimepath&')
meths.command('set backupdir&')
meths.command('set directory&')
@ -466,15 +466,15 @@ describe('XDG defaults', function()
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/'))
eq(('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
meths.get_option('backupdir'):gsub('\\', '/'))
meths.get_option_value('backupdir', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
meths.get_option('directory'):gsub('\\', '/'))
meths.get_option_value('directory', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
meths.get_option('undodir'):gsub('\\', '/'))
meths.get_option_value('undodir', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
meths.get_option('viewdir'):gsub('\\', '/'))
meths.get_option_value('viewdir', {}):gsub('\\', '/'))
meths.command('set all&')
eq(('$XDG_DATA_HOME/nvim'
.. ',$XDG_DATA_DIRS/nvim'
@ -486,15 +486,15 @@ describe('XDG defaults', function()
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/'), (meths.get_option('runtimepath')):gsub('\\', '/'))
):gsub('\\', '/'), (meths.get_option_value('runtimepath', {})):gsub('\\', '/'))
eq(('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
meths.get_option('backupdir'):gsub('\\', '/'))
meths.get_option_value('backupdir', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
meths.get_option('directory'):gsub('\\', '/'))
meths.get_option_value('directory', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
meths.get_option('undodir'):gsub('\\', '/'))
meths.get_option_value('undodir', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
meths.get_option('viewdir'):gsub('\\', '/'))
meths.get_option_value('viewdir', {}):gsub('\\', '/'))
eq(nil, (funcs.tempname()):match('XDG_RUNTIME_DIR'))
end)
end)
@ -529,7 +529,7 @@ describe('XDG defaults', function()
.. ',-\\,-\\,-' .. path_sep .. 'nvim' .. path_sep .. 'after'
.. ',\\,-\\,-\\,' .. path_sep .. 'nvim' .. path_sep .. 'after'
.. ',\\, \\, \\,' .. path_sep .. 'nvim' .. path_sep .. 'after'
), meths.get_option('runtimepath'))
), meths.get_option_value('runtimepath', {}))
meths.command('set runtimepath&')
meths.command('set backupdir&')
meths.command('set directory&')
@ -549,15 +549,15 @@ describe('XDG defaults', function()
.. ',-\\,-\\,-' .. path_sep ..'nvim' .. path_sep ..'after'
.. ',\\,-\\,-\\,' .. path_sep ..'nvim' .. path_sep ..'after'
.. ',\\, \\, \\,' .. path_sep ..'nvim' .. path_sep ..'after'
), meths.get_option('runtimepath'))
), meths.get_option_value('runtimepath', {}))
eq('.,\\,=\\,=\\,' .. path_sep .. state_dir .. '' .. path_sep ..'backup' .. (path_sep):rep(2),
meths.get_option('backupdir'))
meths.get_option_value('backupdir', {}))
eq('\\,=\\,=\\,' .. path_sep ..'' .. state_dir .. '' .. path_sep ..'swap' .. (path_sep):rep(2),
meths.get_option('directory'))
meths.get_option_value('directory', {}))
eq('\\,=\\,=\\,' .. path_sep ..'' .. state_dir .. '' .. path_sep ..'undo' .. (path_sep):rep(2),
meths.get_option('undodir'))
meths.get_option_value('undodir', {}))
eq('\\,=\\,=\\,' .. path_sep ..'' .. state_dir .. '' .. path_sep ..'view' .. (path_sep):rep(2),
meths.get_option('viewdir'))
meths.get_option_value('viewdir', {}))
end)
end)
end)

View File

@ -11,7 +11,7 @@ local function should_fail(opt, value, errmsg)
feed_command('setlocal ' .. opt .. '=' .. value)
eq(errmsg, eval("v:errmsg"):match("E%d*"))
feed_command('let v:errmsg = ""')
local status, err = pcall(meths.set_option, opt, value)
local status, err = pcall(meths.set_option_value, opt, value, {})
eq(status, false)
eq(errmsg, err:match("E%d*"))
eq('', eval("v:errmsg"))
@ -20,8 +20,8 @@ end
local function should_succeed(opt, value)
feed_command('setglobal ' .. opt .. '=' .. value)
feed_command('setlocal ' .. opt .. '=' .. value)
meths.set_option(opt, value)
eq(value, meths.get_option(opt))
meths.set_option_value(opt, value, {})
eq(value, meths.get_option_value(opt, {}))
eq('', eval("v:errmsg"))
end
@ -29,12 +29,12 @@ describe(':setlocal', function()
before_each(clear)
it('setlocal sets only local value', function()
eq(0, meths.get_option('iminsert'))
eq(0, meths.get_option_value('iminsert', {scope='global'}))
feed_command('setlocal iminsert=1')
eq(0, meths.get_option('iminsert'))
eq(-1, meths.get_option('imsearch'))
eq(0, meths.get_option_value('iminsert', {scope='global'}))
eq(-1, meths.get_option_value('imsearch', {scope='global'}))
feed_command('setlocal imsearch=1')
eq(-1, meths.get_option('imsearch'))
eq(-1, meths.get_option_value('imsearch', {scope='global'}))
end)
end)
@ -77,8 +77,8 @@ describe(':set validation', function()
-- If smaller than 1 this one is set to 'lines'-1
feed_command('setglobal window=-10')
meths.set_option('window', -10)
eq(23, meths.get_option('window'))
meths.set_option_value('window', -10, {})
eq(23, meths.get_option_value('window', {}))
eq('', eval("v:errmsg"))
-- 'scrolloff' and 'sidescrolloff' can have a -1 value when
@ -112,8 +112,8 @@ describe(':set validation', function()
local function setto(value)
feed_command('setglobal maxcombine=' .. value)
feed_command('setlocal maxcombine=' .. value)
meths.set_option('maxcombine', value)
eq(6, meths.get_option('maxcombine'))
meths.set_option_value('maxcombine', value, {})
eq(6, meths.get_option_value('maxcombine', {}))
eq('', eval("v:errmsg"))
end
setto(0)

View File

@ -3,7 +3,6 @@ local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local pathsep = helpers.get_pathsep()
local curbufmeths = helpers.curbufmeths
local funcs = helpers.funcs
local meths = helpers.meths
@ -13,7 +12,7 @@ local function test_case(name, expected)
local filename = testdir .. pathsep .. name
command('edit ' .. filename)
for opt, val in pairs(expected) do
eq(val, curbufmeths.get_option(opt), name)
eq(val, meths.get_option_value(opt, {buf=0}), name)
end
end

View File

@ -21,7 +21,7 @@ before_each(function ()
-- ["mac"] = '\r',
-- }
-- local line_ending = format_line_ending[vim.api.nvim_buf_get_option(0, 'fileformat')]
-- local line_ending = format_line_ending[vim.api.nvim_get_option_value('fileformat', {buf=0})]
function test_register(bufnr, id, offset_encoding, line_ending)

View File

@ -33,7 +33,9 @@ local test_rpc_server = lsp_helpers.test_rpc_server
local function get_buf_option(name, bufnr)
bufnr = bufnr or "BUFFER"
return exec_lua(string.format("return vim.api.nvim_buf_get_option(%s, '%s')", bufnr, name))
return exec_lua(
string.format("return vim.api.nvim_get_option_value('%s', { buf = %s })", name, bufnr)
)
end
-- TODO(justinmk): hangs on Windows https://github.com/neovim/neovim/pull/11837
@ -356,8 +358,8 @@ describe('LSP', function()
vim.api.nvim_command('filetype plugin on')
BUFFER_1 = vim.api.nvim_create_buf(false, true)
BUFFER_2 = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_option(BUFFER_1, 'filetype', 'man')
vim.api.nvim_buf_set_option(BUFFER_2, 'filetype', 'xml')
vim.api.nvim_set_option_value('filetype', 'man', { buf = BUFFER_1 })
vim.api.nvim_set_option_value('filetype', 'xml', { buf = BUFFER_2 })
]]
-- Sanity check to ensure that some values are set after setting filetype.
@ -394,9 +396,9 @@ describe('LSP', function()
client = _client
exec_lua [[
BUFFER = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_option(BUFFER, 'tagfunc', 'tfu')
vim.api.nvim_buf_set_option(BUFFER, 'omnifunc', 'ofu')
vim.api.nvim_buf_set_option(BUFFER, 'formatexpr', 'fex')
vim.api.nvim_set_option_value('tagfunc', 'tfu', { buf = BUFFER })
vim.api.nvim_set_option_value('omnifunc', 'ofu', { buf = BUFFER })
vim.api.nvim_set_option_value('formatexpr', 'fex', { buf = BUFFER })
lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)
]]
end;
@ -1166,7 +1168,7 @@ describe('LSP', function()
"testing";
"123";
})
vim.api.nvim_buf_set_option(BUFFER, 'eol', false)
vim.bo[BUFFER].eol = false
]]
end;
on_init = function(_client)
@ -2929,8 +2931,8 @@ describe('LSP', function()
describe('lsp.util.get_effective_tabstop', function()
local function test_tabstop(tabsize, shiftwidth)
exec_lua(string.format([[
vim.api.nvim_buf_set_option(0, 'shiftwidth', %d)
vim.api.nvim_buf_set_option(0, 'tabstop', 2)
vim.bo.shiftwidth = %d
vim.bo.tabstop = 2
]], shiftwidth))
eq(tabsize, exec_lua('return vim.lsp.util.get_effective_tabstop()'))
end

View File

@ -2181,8 +2181,8 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "a"',
}, nvim_eval('getline(1, "$")'))
eq(false, curbuf('get_option', 'modified'))
eq('shada', curbuf('get_option', 'filetype'))
eq(false, nvim('get_option_value', 'modified', {buf=0}))
eq('shada', nvim('get_option_value', 'filetype', {buf=0}))
nvim_command('edit ' .. fname_tmp)
eq({
'History entry with timestamp ' .. epoch .. ':',
@ -2191,8 +2191,8 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "b"',
}, nvim_eval('getline(1, "$")'))
eq(false, curbuf('get_option', 'modified'))
eq('shada', curbuf('get_option', 'filetype'))
eq(false, nvim('get_option_value', 'modified', {buf=0}))
eq('shada', nvim('get_option_value', 'filetype', {buf=0}))
eq('++opt not supported', exc_exec('edit ++enc=latin1 ' .. fname))
neq({
'History entry with timestamp ' .. epoch .. ':',
@ -2201,7 +2201,7 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "a"',
}, nvim_eval('getline(1, "$")'))
neq(true, curbuf('get_option', 'modified'))
neq(true, nvim('get_option_value', 'modified', {buf=0}))
end)
it('event FileReadCmd', function()
@ -2217,8 +2217,8 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "a"',
}, nvim_eval('getline(1, "$")'))
eq(true, curbuf('get_option', 'modified'))
neq('shada', curbuf('get_option', 'filetype'))
eq(true, nvim('get_option_value', 'modified', {buf=0}))
neq('shada', nvim('get_option_value', 'filetype', {buf=0}))
nvim_command('1,$read ' .. fname_tmp)
eq({
'',
@ -2233,9 +2233,9 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "b"',
}, nvim_eval('getline(1, "$")'))
eq(true, curbuf('get_option', 'modified'))
neq('shada', curbuf('get_option', 'filetype'))
curbuf('set_option', 'modified', false)
eq(true, nvim('get_option_value', 'modified', {buf=0}))
neq('shada', nvim('get_option_value', 'filetype', {buf=0}))
nvim('set_option_value', 'modified', false, {buf=0})
eq('++opt not supported', exc_exec('$read ++enc=latin1 ' .. fname))
eq({
'',
@ -2250,7 +2250,7 @@ describe('plugin/shada.vim', function()
' - contents "ab"',
' - "b"',
}, nvim_eval('getline(1, "$")'))
neq(true, curbuf('get_option', 'modified'))
neq(true, nvim('get_option_value', 'modified', {buf=0}))
end)
it('event BufWriteCmd', function()
@ -2517,10 +2517,10 @@ describe('ftplugin/shada.vim', function()
it('sets options correctly', function()
nvim_command('filetype plugin indent on')
nvim_command('setlocal filetype=shada')
eq(true, curbuf('get_option', 'expandtab'))
eq(2, curbuf('get_option', 'tabstop'))
eq(2, curbuf('get_option', 'softtabstop'))
eq(2, curbuf('get_option', 'shiftwidth'))
eq(true, nvim('get_option_value', 'expandtab', {buf=0}))
eq(2, nvim('get_option_value', 'tabstop', {buf=0}))
eq(2, nvim('get_option_value', 'softtabstop', {buf=0}))
eq(2, nvim('get_option_value', 'shiftwidth', {buf=0}))
end)
it('sets indentkeys correctly', function()

View File

@ -5,7 +5,7 @@ local command = helpers.command
local write_file = helpers.write_file
local eval = helpers.eval
local retry = helpers.retry
local curbufmeths = helpers.curbufmeths
local meths = helpers.meths
local insert = helpers.insert
local expect = helpers.expect
local feed = helpers.feed
@ -45,7 +45,7 @@ describe('legacy perl provider', function()
-- :perldo 1; doesn't change $_,
-- the buffer should not be changed
command('normal :perldo 1;')
eq(false, curbufmeths.get_option('modified'))
eq(false, meths.get_option_value('modified', {buf=0}))
-- insert some text
insert('abc\ndef\nghi')
expect([[

View File

@ -3,7 +3,6 @@ local helpers = require('test.functional.helpers')(after_each)
local assert_alive = helpers.assert_alive
local clear = helpers.clear
local command = helpers.command
local curbufmeths = helpers.curbufmeths
local eq = helpers.eq
local exc_exec = helpers.exc_exec
local expect = helpers.expect
@ -98,7 +97,7 @@ describe(':rubydo command', function()
it('does not modify the buffer if no changes are made', function()
command('normal :rubydo 42')
eq(false, curbufmeths.get_option('modified'))
eq(false, meths.get_option_value('modified', {buf=0}))
end)
end)

View File

@ -1,7 +1,7 @@
-- shada buffer list saving/reading support
local helpers = require('test.functional.helpers')(after_each)
local nvim_command, funcs, eq, curbufmeths =
helpers.command, helpers.funcs, helpers.eq, helpers.curbufmeths
local nvim_command, funcs, eq, curbufmeths, meths =
helpers.command, helpers.funcs, helpers.eq, helpers.curbufmeths, helpers.meths
local expect_exit = helpers.expect_exit
local shada_helpers = require('test.functional.shada.helpers')
@ -48,7 +48,7 @@ describe('shada support code', function()
reset('set shada+=%')
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
curbufmeths.set_option('buflisted', false)
meths.set_option_value('buflisted', false, {buf=0})
expect_exit(nvim_command, 'qall')
reset('set shada+=%')
eq(2, funcs.bufnr('$'))
@ -60,7 +60,7 @@ describe('shada support code', function()
reset('set shada+=%')
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
curbufmeths.set_option('buftype', 'quickfix')
meths.set_option_value('buftype', 'quickfix', {buf=0})
expect_exit(nvim_command, 'qall')
reset('set shada+=%')
eq(2, funcs.bufnr('$'))

View File

@ -106,13 +106,13 @@ describe('ShaDa support code', function()
end)
it('dumps and loads last search pattern with offset', function()
meths.set_option('wrapscan', false)
meths.set_option_value('wrapscan', false, {})
funcs.setline('.', {'foo', 'bar--'})
nvim_feed('gg0/a/e+1\n')
eq({0, 2, 3, 0}, funcs.getpos('.'))
nvim_command('wshada')
reset()
meths.set_option('wrapscan', false)
meths.set_option_value('wrapscan', false, {})
funcs.setline('.', {'foo', 'bar--'})
nvim_feed('gg0n')
eq({0, 2, 3, 0}, funcs.getpos('.'))
@ -121,13 +121,13 @@ describe('ShaDa support code', function()
it('dumps and loads last search pattern with offset and backward direction',
function()
meths.set_option('wrapscan', false)
meths.set_option_value('wrapscan', false, {})
funcs.setline('.', {'foo', 'bar--'})
nvim_feed('G$?a?e+1\n')
eq({0, 2, 3, 0}, funcs.getpos('.'))
nvim_command('wshada')
reset()
meths.set_option('wrapscan', false)
meths.set_option_value('wrapscan', false, {})
funcs.setline('.', {'foo', 'bar--'})
nvim_feed('G$n')
eq({0, 2, 3, 0}, funcs.getpos('.'))

View File

@ -196,30 +196,30 @@ describe('ShaDa support code', function()
end)
it('is able to set &shada after &viminfo', function()
meths.set_option('viminfo', '\'10')
eq('\'10', meths.get_option('viminfo'))
eq('\'10', meths.get_option('shada'))
meths.set_option('shada', '')
eq('', meths.get_option('viminfo'))
eq('', meths.get_option('shada'))
meths.set_option_value('viminfo', '\'10', {})
eq('\'10', meths.get_option_value('viminfo', {}))
eq('\'10', meths.get_option_value('shada', {}))
meths.set_option_value('shada', '', {})
eq('', meths.get_option_value('viminfo', {}))
eq('', meths.get_option_value('shada', {}))
end)
it('is able to set all& after setting &shada', function()
meths.set_option('shada', '\'10')
eq('\'10', meths.get_option('viminfo'))
eq('\'10', meths.get_option('shada'))
meths.set_option_value('shada', '\'10', {})
eq('\'10', meths.get_option_value('viminfo', {}))
eq('\'10', meths.get_option_value('shada', {}))
nvim_command('set all&')
eq('!,\'100,<50,s10,h', meths.get_option('viminfo'))
eq('!,\'100,<50,s10,h', meths.get_option('shada'))
eq('!,\'100,<50,s10,h', meths.get_option_value('viminfo', {}))
eq('!,\'100,<50,s10,h', meths.get_option_value('shada', {}))
end)
it('is able to set &shada after &viminfo using :set', function()
nvim_command('set viminfo=\'10')
eq('\'10', meths.get_option('viminfo'))
eq('\'10', meths.get_option('shada'))
eq('\'10', meths.get_option_value('viminfo', {}))
eq('\'10', meths.get_option_value('shada', {}))
nvim_command('set shada=')
eq('', meths.get_option('viminfo'))
eq('', meths.get_option('shada'))
eq('', meths.get_option_value('viminfo', {}))
eq('', meths.get_option_value('shada', {}))
end)
it('setting &shada gives proper error message on missing number', function()
@ -237,12 +237,12 @@ describe('ShaDa support code', function()
funcs.mkdir(dirname, '', 0)
eq(0, funcs.filewritable(dirname))
reset{shadafile=dirshada, args={'--cmd', 'set shada='}}
meths.set_option('shada', '\'10')
meths.set_option_value('shada', '\'10', {})
eq('Vim(wshada):E886: System error while opening ShaDa file '
.. 'Xtest-functional-shada-shada.d/main.shada for reading to merge '
.. 'before writing it: permission denied',
exc_exec('wshada'))
meths.set_option('shada', '')
meths.set_option_value('shada', '', {})
end)
end)

View File

@ -197,7 +197,7 @@ describe(':terminal buffer', function()
it('handles loss of focus gracefully', function()
-- Change the statusline to avoid printing the file name, which varies.
nvim('set_option', 'statusline', '==========')
nvim('set_option_value', 'statusline', '==========', {})
feed_command('set laststatus=0')
-- Save the buffer number of the terminal for later testing.

View File

@ -21,8 +21,8 @@ describe(':edit term://*', function()
before_each(function()
clear()
meths.set_option('shell', testprg('shell-test'))
meths.set_option('shellcmdflag', 'EXE')
meths.set_option_value('shell', testprg('shell-test'), {})
meths.set_option_value('shellcmdflag', 'EXE', {})
end)
it('runs TermOpen event', function()
@ -40,7 +40,7 @@ describe(':edit term://*', function()
local columns, lines = 20, 4
local scr = get_screen(columns, lines)
local rep = 97
meths.set_option('shellcmdflag', 'REP ' .. rep)
meths.set_option_value('shellcmdflag', 'REP ' .. rep, {})
command('set shellxquote=') -- win: avoid extra quotes
local sb = 10
command('autocmd TermOpen * :setlocal scrollback='..tostring(sb)

View File

@ -133,8 +133,8 @@ describe(':terminal (with fake shell)', function()
screen = Screen.new(50, 4)
screen:attach({rgb=false})
-- shell-test.c is a fake shell that prints its arguments and exits.
nvim('set_option', 'shell', testprg('shell-test'))
nvim('set_option', 'shellcmdflag', 'EXE')
nvim('set_option_value', 'shell', testprg('shell-test'), {})
nvim('set_option_value', 'shellcmdflag', 'EXE', {})
end)
-- Invokes `:terminal {cmd}` using a fake shell (shell-test.c) which prints
@ -157,7 +157,7 @@ describe(':terminal (with fake shell)', function()
end)
it("with no argument, and 'shell' is set to empty string", function()
nvim('set_option', 'shell', '')
nvim('set_option_value', 'shell', '', {})
terminal_with_fake_shell()
screen:expect([[
^ |
@ -169,7 +169,7 @@ describe(':terminal (with fake shell)', function()
it("with no argument, but 'shell' has arguments, acts like termopen()", function()
skip(is_os('win'))
nvim('set_option', 'shell', testprg('shell-test')..' -t jeff')
nvim('set_option_value', 'shell', testprg('shell-test')..' -t jeff', {})
terminal_with_fake_shell()
screen:expect([[
^jeff $ |
@ -193,7 +193,7 @@ describe(':terminal (with fake shell)', function()
it("executes a given command through the shell, when 'shell' has arguments", function()
skip(is_os('win'))
nvim('set_option', 'shell', testprg('shell-test')..' -t jeff')
nvim('set_option_value', 'shell', testprg('shell-test')..' -t jeff', {})
command('set shellxquote=') -- win: avoid extra quotes
terminal_with_fake_shell('echo hi')
screen:expect([[

View File

@ -11,7 +11,7 @@ describe(':terminal mouse', function()
before_each(function()
clear()
nvim('set_option', 'statusline', '==========')
nvim('set_option_value', 'statusline', '==========', {})
command('highlight StatusLine cterm=NONE')
command('highlight StatusLineNC cterm=NONE')
command('highlight VertSplit cterm=NONE')
@ -352,7 +352,7 @@ describe(':terminal mouse', function()
end)
it('handles terminal size when switching buffers', function()
nvim('set_option', 'hidden', true)
nvim('set_option_value', 'hidden', true, {})
feed('<c-\\><c-n><c-w><c-w>')
screen:expect([[
{7: 27 }line line30 |

View File

@ -8,7 +8,7 @@ local command = helpers.command
local matches = helpers.matches
local poke_eventloop = helpers.poke_eventloop
local retry = helpers.retry
local curbufmeths = helpers.curbufmeths
local meths = helpers.meths
local nvim = helpers.nvim
local feed_data = thelpers.feed_data
local pcall_err = helpers.pcall_err
@ -381,8 +381,8 @@ describe("'scrollback' option", function()
local function set_fake_shell()
-- shell-test.c is a fake shell that prints its arguments and exits.
nvim('set_option', 'shell', testprg('shell-test'))
nvim('set_option', 'shellcmdflag', 'EXE')
nvim('set_option_value', 'shell', testprg('shell-test'), {})
nvim('set_option_value', 'shellcmdflag', 'EXE', {})
end
local function expect_lines(expected, epsilon)
@ -401,7 +401,7 @@ describe("'scrollback' option", function()
screen = thelpers.screen_setup(nil, "['sh']", 30)
end
curbufmeths.set_option('scrollback', 0)
meths.set_option_value('scrollback', 0, {buf = 0})
feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n'))
screen:expect{any='30: line '}
retry(nil, nil, function() expect_lines(7) end)
@ -417,7 +417,7 @@ describe("'scrollback' option", function()
screen = thelpers.screen_setup(nil, "['sh']", 30)
end
curbufmeths.set_option('scrollback', 200)
meths.set_option_value('scrollback', 200, {buf=0})
-- Wait for prompt.
screen:expect{any='%$'}
@ -426,10 +426,10 @@ describe("'scrollback' option", function()
screen:expect{any='30: line '}
retry(nil, nil, function() expect_lines(33, 2) end)
curbufmeths.set_option('scrollback', 10)
meths.set_option_value('scrollback', 10, {buf=0})
poke_eventloop()
retry(nil, nil, function() expect_lines(16) end)
curbufmeths.set_option('scrollback', 10000)
meths.set_option_value('scrollback', 10000, {buf=0})
retry(nil, nil, function() expect_lines(16) end)
-- Terminal job data is received asynchronously, may happen before the
-- 'scrollback' option is synchronized with the internal sb_buffer.
@ -484,18 +484,18 @@ describe("'scrollback' option", function()
]])
local term_height = 6 -- Actual terminal screen height, not the scrollback
-- Initial
local scrollback = curbufmeths.get_option('scrollback')
local scrollback = meths.get_option_value('scrollback', {buf=0})
eq(scrollback + term_height, eval('line("$")'))
-- Reduction
scrollback = scrollback - 2
curbufmeths.set_option('scrollback', scrollback)
meths.set_option_value('scrollback', scrollback, {buf=0})
eq(scrollback + term_height, eval('line("$")'))
end)
it('defaults to 10000 in :terminal buffers', function()
set_fake_shell()
command('terminal')
eq(10000, curbufmeths.get_option('scrollback'))
eq(10000, meths.get_option_value('scrollback', {buf=0}))
end)
it('error if set to invalid value', function()
@ -507,7 +507,7 @@ describe("'scrollback' option", function()
it('defaults to -1 on normal buffers', function()
command('new')
eq(-1, curbufmeths.get_option('scrollback'))
eq(-1, meths.get_option_value('scrollback', {buf=0}))
end)
it(':setlocal in a :terminal buffer', function()
@ -516,45 +516,45 @@ describe("'scrollback' option", function()
-- _Global_ scrollback=-1 defaults :terminal to 10_000.
command('setglobal scrollback=-1')
command('terminal')
eq(10000, curbufmeths.get_option('scrollback'))
eq(10000, meths.get_option_value('scrollback', {buf=0}))
-- _Local_ scrollback=-1 in :terminal forces the _maximum_.
command('setlocal scrollback=-1')
retry(nil, nil, function() -- Fixup happens on refresh, not immediately.
eq(100000, curbufmeths.get_option('scrollback'))
eq(100000, meths.get_option_value('scrollback', {buf=0}))
end)
-- _Local_ scrollback=-1 during TermOpen forces the maximum. #9605
command('setglobal scrollback=-1')
command('autocmd TermOpen * setlocal scrollback=-1')
command('terminal')
eq(100000, curbufmeths.get_option('scrollback'))
eq(100000, meths.get_option_value('scrollback', {buf=0}))
end)
it(':setlocal in a normal buffer', function()
command('new')
-- :setlocal to -1.
command('setlocal scrollback=-1')
eq(-1, curbufmeths.get_option('scrollback'))
eq(-1, meths.get_option_value('scrollback', {buf=0}))
-- :setlocal to anything except -1. Currently, this just has no effect.
command('setlocal scrollback=42')
eq(42, curbufmeths.get_option('scrollback'))
eq(42, meths.get_option_value('scrollback', {buf=0}))
end)
it(':set updates local value and global default', function()
set_fake_shell()
command('set scrollback=42') -- set global value
eq(42, curbufmeths.get_option('scrollback'))
eq(42, meths.get_option_value('scrollback', {buf=0}))
command('terminal')
eq(42, curbufmeths.get_option('scrollback')) -- inherits global default
eq(42, meths.get_option_value('scrollback', {buf=0})) -- inherits global default
command('setlocal scrollback=99')
eq(99, curbufmeths.get_option('scrollback'))
eq(99, meths.get_option_value('scrollback', {buf=0}))
command('set scrollback<') -- reset to global default
eq(42, curbufmeths.get_option('scrollback'))
eq(42, meths.get_option_value('scrollback', {buf=0}))
command('setglobal scrollback=734') -- new global default
eq(42, curbufmeths.get_option('scrollback')) -- local value did not change
eq(42, meths.get_option_value('scrollback', {buf=0})) -- local value did not change
command('terminal')
eq(734, curbufmeths.get_option('scrollback'))
eq(734, meths.get_option_value('scrollback', {buf=0}))
end)
end)
@ -578,7 +578,7 @@ describe("pending scrollback line handling", function()
local api = vim.api
local buf = api.nvim_create_buf(true, true)
local chan = api.nvim_open_term(buf, {})
api.nvim_win_set_option(0, "number", true)
vim.wo.number = true
api.nvim_chan_send(chan, ("a\n"):rep(11) .. "a")
api.nvim_win_set_buf(0, buf)
]]

View File

@ -1458,9 +1458,9 @@ describe('TUI', function()
it('allows grid to assume wider ambiguous-width characters than host terminal #19686', function()
child_session:request('nvim_buf_set_lines', 0, 0, -1, true, { (''):rep(60), (''):rep(60) })
child_session:request('nvim_win_set_option', 0, 'cursorline', true)
child_session:request('nvim_win_set_option', 0, 'list', true)
child_session:request('nvim_win_set_option', 0, 'listchars', 'eol:$')
child_session:request('nvim_set_option_value', 'cursorline', true, {win=0})
child_session:request('nvim_set_option_value', 'list', true, {win=0})
child_session:request('nvim_set_option_value', 'listchars', 'eol:$', {win=0})
feed_data('gg')
local singlewidth_screen = [[
{13:}{12:}|
@ -1483,9 +1483,9 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]]
screen:expect(singlewidth_screen)
child_session:request('nvim_set_option', 'ambiwidth', 'double')
child_session:request('nvim_set_option_value', 'ambiwidth', 'double', {})
screen:expect(doublewidth_screen)
child_session:request('nvim_set_option', 'ambiwidth', 'single')
child_session:request('nvim_set_option_value', 'ambiwidth', 'single', {})
screen:expect(singlewidth_screen)
child_session:request('nvim_call_function', 'setcellwidths', {{{0x2103, 0x2103, 2}}})
screen:expect(doublewidth_screen)

View File

@ -19,7 +19,7 @@ describe(':terminal', function()
clear()
-- set the statusline to a constant value because of variables like pid
-- and current directory and to improve visibility of splits
meths.set_option('statusline', '==========')
meths.set_option_value('statusline', '==========', {})
command('highlight StatusLine cterm=NONE')
command('highlight StatusLineNC cterm=NONE')
command('highlight VertSplit cterm=NONE')
@ -71,7 +71,7 @@ describe(':terminal', function()
end)
it('does not change size if updated when not visible in any window #19665', function()
local channel = meths.buf_get_option(0, 'channel')
local channel = meths.get_option_value('channel', { buf = 0 })
command('enew')
sleep(100)
meths.chan_send(channel, 'foo')

View File

@ -178,7 +178,7 @@ end
describe('Command-line coloring', function()
it('works', function()
set_color_cb('RainBowParens')
meths.set_option('more', false)
meths.set_option_value('more', false, {})
start_prompt()
screen:expect([[
|

View File

@ -265,8 +265,8 @@ describe('ui/cursor', function()
}
-- Another cursor style.
meths.set_option('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173'
..',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42')
meths.set_option_value('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173'
..',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42', {})
screen:expect(function()
local named = {}
for _, m in ipairs(screen._mode_info) do
@ -288,7 +288,7 @@ describe('ui/cursor', function()
end)
-- If there is no setting for guicursor, it becomes the default setting.
meths.set_option('guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor')
meths.set_option_value('guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor', {})
screen:expect(function()
for _,m in ipairs(screen._mode_info) do
if m.name ~= 'normal' then
@ -304,7 +304,7 @@ describe('ui/cursor', function()
end)
it("empty 'guicursor' sets cursor_shape=block in all modes", function()
meths.set_option('guicursor', '')
meths.set_option_value('guicursor', '', {})
screen:expect(function()
-- Empty 'guicursor' sets enabled=false.
eq(false, screen._cursor_style_enabled)

View File

@ -1910,7 +1910,7 @@ describe('decorations: signs', function()
}
ns = meths.create_namespace 'test'
meths.win_set_option(0, 'signcolumn', 'auto:9')
meths.set_option_value('signcolumn', 'auto:9', {win = 0})
end)
local example_text = [[
@ -2222,7 +2222,7 @@ l5
]]}
-- Check truncation works too
meths.win_set_option(0, 'signcolumn', 'auto')
meths.set_option_value('signcolumn', 'auto', {win = 0})
screen:expect{grid=[[
S5^l1 |
@ -2233,7 +2233,7 @@ l5
it('does not set signcolumn for signs without text', function()
screen:try_resize(20, 3)
meths.win_set_option(0, 'signcolumn', 'auto')
meths.set_option_value('signcolumn', 'auto', {win = 0})
insert(example_text)
feed 'gg'
meths.buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'})

View File

@ -105,7 +105,7 @@ describe('float window', function()
it('opened with correct height', function()
local height = exec_lua([[
vim.api.nvim_set_option("winheight", 20)
vim.go.winheight = 20
local bufnr = vim.api.nvim_create_buf(false, true)
local opts = {
@ -127,7 +127,7 @@ describe('float window', function()
it('opened with correct width', function()
local width = exec_lua([[
vim.api.nvim_set_option("winwidth", 20)
vim.go.winwidth = 20
local bufnr = vim.api.nvim_create_buf(false, true)
local opts = {
@ -427,36 +427,36 @@ describe('float window', function()
it("no segfault when setting minimal style after clearing local 'fillchars' #19510", function()
local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
local float_win = meths.open_win(0, true, float_opts)
meths.win_set_option(float_win, 'fillchars', NIL)
meths.set_option_value('fillchars', NIL, {win=float_win.id})
float_opts.style = 'minimal'
meths.win_set_config(float_win, float_opts)
assert_alive()
end)
end)
it("should re-apply 'style' when present", function()
it("should re-apply 'style' when present", function()
local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1}
local float_win = meths.open_win(0, true, float_opts)
meths.win_set_option(float_win, 'number', true)
meths.set_option_value('number', true, { win = float_win })
float_opts.row = 2
meths.win_set_config(float_win, float_opts)
eq(false, meths.win_get_option(float_win, 'number'))
eq(false, meths.get_option_value('number', { win = float_win }))
end)
it("should not re-apply 'style' when missing", function()
local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1}
local float_win = meths.open_win(0, true, float_opts)
meths.win_set_option(float_win, 'number', true)
meths.set_option_value('number', true, { win = float_win })
float_opts.row = 2
float_opts.style = nil
meths.win_set_config(float_win, float_opts)
eq(true, meths.win_get_option(float_win, 'number'))
eq(true, meths.get_option_value('number', { win = float_win }))
end)
it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function()
meths.set_option('splitkeep', 'screen')
meths.set_option_value('splitkeep', 'screen', {})
local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10}
local float_win = meths.open_win(0, true, float_opts)
eq(5, meths.win_get_option(float_win, 'scroll'))
eq(5, meths.get_option_value('scroll', {win=float_win.id}))
end)
describe('with only one tabpage,', function()
@ -4553,8 +4553,8 @@ describe('float window', function()
describe('and completion', function()
before_each(function()
local buf = meths.create_buf(false,false)
local win = meths.open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5})
meths.win_set_option(win , 'winhl', 'Normal:ErrorMsg')
local win = meths.open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5}).id
meths.set_option_value('winhl', 'Normal:ErrorMsg', {win=win})
if multigrid then
screen:expect{grid=[[
## grid 1
@ -7823,7 +7823,7 @@ describe('float window', function()
local buf = meths.create_buf(false,false)
meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'})
local float_win = meths.open_win(buf, false, {relative='editor', width=20, height=4, row=1, col=5})
meths.win_set_option(float_win, 'winbar', 'floaty bar')
meths.set_option_value('winbar', 'floaty bar', {win=float_win.id})
if multigrid then
screen:expect{grid=[[
## grid 1
@ -8144,7 +8144,7 @@ describe('float window', function()
]])
end
meths.win_set_option(win, "winblend", 30)
meths.set_option_value("winblend", 30, {win=win.id})
if multigrid then
screen:expect{grid=[[
## grid 1
@ -8452,7 +8452,7 @@ describe('float window', function()
-- at least. Also check invisible EndOfBuffer region blends correctly.
meths.buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"})
win = meths.open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'})
meths.win_set_option(win, 'winblend', 30)
meths.set_option_value('winblend', 30, {win=win.id})
screen:set_default_attr_ids({
[1] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')},
[2] = {foreground = Screen.colors.Grey0, background = tonumber('0xffcfff')},
@ -8694,7 +8694,7 @@ describe('float window', function()
it("correctly orders multiple opened floats (current last)", function()
local buf = meths.create_buf(false,false)
local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id})
if multigrid then
screen:expect{grid=[[
@ -8739,10 +8739,10 @@ describe('float window', function()
exec_lua [[
local buf = vim.api.nvim_create_buf(false,false)
local win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8})
vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal")
vim.wo[win].winhl = "EndOfBuffer:Normal"
buf = vim.api.nvim_create_buf(false,false)
win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10})
vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search")
vim.wo[win].winhl = "Normal:Search,EndOfBuffer:Search"
]]
if multigrid then
@ -8799,7 +8799,7 @@ describe('float window', function()
it("correctly orders multiple opened floats (non-current last)", function()
local buf = meths.create_buf(false,false)
local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id})
if multigrid then
screen:expect{grid=[[
@ -8844,10 +8844,10 @@ describe('float window', function()
exec_lua [[
local buf = vim.api.nvim_create_buf(false,false)
local win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10})
vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search")
vim.wo[win].winhl = "Normal:Search,EndOfBuffer:Search"
buf = vim.api.nvim_create_buf(false,false)
win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8})
vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal")
vim.wo[win].winhl = "EndOfBuffer:Normal"
]]
if multigrid then
@ -8904,11 +8904,11 @@ describe('float window', function()
it('can use z-index', function()
local buf = meths.create_buf(false,false)
local win1 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=1, col=5, zindex=30})
meths.win_set_option(win1, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win1.id})
local win2 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=6, zindex=50})
meths.win_set_option(win2, "winhl", "Normal:Search,EndOfBuffer:Search")
meths.set_option_value("winhl", "Normal:Search,EndOfBuffer:Search", {win=win2.id})
local win3 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=3, col=7, zindex=40})
meths.win_set_option(win3, "winhl", "Normal:Question,EndOfBuffer:Question")
meths.set_option_value("winhl", "Normal:Question,EndOfBuffer:Question", {win=win3.id})
if multigrid then
screen:expect{grid=[[
@ -8967,7 +8967,7 @@ describe('float window', function()
it('can use winbar', function()
local buf = meths.create_buf(false,false)
local win1 = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5})
meths.win_set_option(win1, 'winbar', 'floaty bar')
meths.set_option_value('winbar', 'floaty bar', {win=win1.id})
if multigrid then
screen:expect{grid=[[

View File

@ -967,8 +967,8 @@ describe("folded lines", function()
it("works with multibyte text", function()
-- Currently the only allowed value of 'maxcombine'
eq(6, meths.get_option('maxcombine'))
eq(true, meths.get_option('arabicshape'))
eq(6, meths.get_option_value('maxcombine', {}))
eq(true, meths.get_option_value('arabicshape', {}))
insert([[
å x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة
möre text]])

View File

@ -2,7 +2,6 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
local curbufmeths = helpers.curbufmeths
local eq = helpers.eq
local eval = helpers.eval
local feed_command = helpers.feed_command
@ -178,8 +177,8 @@ describe(":substitute, 'inccommand' preserves", function()
feed_command("set inccommand=" .. case)
insert("as")
feed(":%s/as/glork/<enter>")
eq(meths.get_option('undolevels'), 139)
eq(curbufmeths.get_option('undolevels'), 34)
eq(meths.get_option_value('undolevels', {scope='global'}), 139)
eq(meths.get_option_value('undolevels', {buf=0}), 34)
end)
end
@ -1192,7 +1191,7 @@ describe(":substitute, inccommand=split", function()
it("deactivates if 'redrawtime' is exceeded #5602", function()
-- prevent redraws from 'incsearch'
meths.set_option('incsearch', false)
meths.set_option_value('incsearch', false, {})
-- Assert that 'inccommand' is ENABLED initially.
eq("split", eval("&inccommand"))
-- Set 'redrawtime' to minimal value, to ensure timeout is triggered.
@ -2465,16 +2464,14 @@ describe(":substitute", function()
end)
it("inccommand=split, contraction of two subsequent NL chars", function()
-- luacheck: push ignore 611
local text = [[
AAA AA
BBB BB
CCC CC
]]
-- luacheck: pop
-- This used to crash, but more than 20 highlight entries are required
-- to reproduce it (so that the marktree has multiple nodes)
@ -2501,16 +2498,14 @@ describe(":substitute", function()
end)
it("inccommand=nosplit, contraction of two subsequent NL chars", function()
-- luacheck: push ignore 611
local text = [[
AAA AA
BBB BB
CCC CC
]]
-- luacheck: pop
common_setup(screen, "nosplit", string.rep(text,10))
feed(":%s/\\n\\n/<c-v><c-m>/g")

View File

@ -391,7 +391,7 @@ describe("'inccommand' for user commands", function()
vim.api.nvim_create_user_command('Replace', function() end, {
nargs = '*',
preview = function()
vim.api.nvim_set_option('inccommand', 'split')
vim.api.nvim_set_option_value('inccommand', 'split', {})
return 2
end,
})

View File

@ -1273,7 +1273,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
{1:~ }|
|
]])
eq(1, meths.get_option('cmdheight'))
eq(1, meths.get_option_value('cmdheight', {}))
end)
end)

View File

@ -11,8 +11,8 @@ describe('ui/mouse/input', function()
before_each(function()
clear()
meths.set_option('mouse', 'a')
meths.set_option('list', true)
meths.set_option_value('mouse', 'a', {})
meths.set_option_value('list', true, {})
-- NB: this is weird, but mostly irrelevant to the test
-- So I didn't bother to change it
command('set listchars=eol:$')
@ -64,7 +64,7 @@ describe('ui/mouse/input', function()
end)
it("in external ui works with unset 'mouse'", function()
meths.set_option('mouse', '')
meths.set_option_value('mouse', '', {})
feed('<LeftMouse><2,1>')
screen:expect{grid=[[
testing |
@ -379,7 +379,7 @@ describe('ui/mouse/input', function()
end)
it('left click in default tabline (position 24) closes tab', function()
meths.set_option('hidden', true)
meths.set_option_value('hidden', true, {})
feed_command('%delete')
insert('this is foo')
feed_command('silent file foo | tabnew | file bar')
@ -402,7 +402,7 @@ describe('ui/mouse/input', function()
end)
it('double click in default tabline (position 4) opens new tab', function()
meths.set_option('hidden', true)
meths.set_option_value('hidden', true, {})
feed_command('%delete')
insert('this is foo')
feed_command('silent file foo | tabnew | file bar')
@ -437,8 +437,8 @@ describe('ui/mouse/input', function()
return call('Test', a:000 + [2])
endfunction
]])
meths.set_option('tabline', '%@Test@test%X-%5@Test2@test2')
meths.set_option('showtabline', 2)
meths.set_option_value('tabline', '%@Test@test%X-%5@Test2@test2', {})
meths.set_option_value('showtabline', 2, {})
screen:expect([[
{fill:test-test2 }|
testing |
@ -786,7 +786,7 @@ describe('ui/mouse/input', function()
end)
it('ctrl + left click will search for a tag', function()
meths.set_option('tags', './non-existent-tags-file')
meths.set_option_value('tags', './non-existent-tags-file', {})
feed('<C-LeftMouse><0,0>')
screen:expect([[
{6:E433: No tags file} |
@ -1577,9 +1577,9 @@ describe('ui/mouse/input', function()
end)
it('getmousepos works correctly', function()
local winwidth = meths.get_option('winwidth')
local winwidth = meths.get_option_value('winwidth', {})
-- Set winwidth=1 so that window sizes don't change.
meths.set_option('winwidth', 1)
meths.set_option_value('winwidth', 1, {})
command('tabedit')
local tabpage = meths.get_current_tabpage()
insert('hello')
@ -1597,8 +1597,8 @@ describe('ui/mouse/input', function()
}
local float = meths.open_win(meths.get_current_buf(), false, opts)
command('redraw')
local lines = meths.get_option('lines')
local columns = meths.get_option('columns')
local lines = meths.get_option_value('lines', {})
local columns = meths.get_option_value('columns', {})
-- Test that screenrow and screencol are set properly for all positions.
for row = 0, lines - 1 do
@ -1696,7 +1696,7 @@ describe('ui/mouse/input', function()
-- Restore state and release mouse.
command('tabclose!')
meths.set_option('winwidth', winwidth)
meths.set_option_value('winwidth', winwidth, {})
meths.input_mouse('left', 'release', '', 0, 0, 0)
end)

View File

@ -3555,7 +3555,7 @@ describe('ext_multigrid', function()
end)
it('with winbar dragging statusline with mouse works correctly', function()
meths.set_option('winbar', 'Set Up The Bars')
meths.set_option_value('winbar', 'Set Up The Bars', {})
command('split')
screen:expect([[
## grid 1
@ -3695,7 +3695,7 @@ describe('ext_multigrid', function()
{1:~ }|
{1:~ }|
]])
eq(3, meths.get_option('cmdheight'))
eq(3, meths.get_option_value('cmdheight', {}))
meths.input_mouse('left', 'drag', '', 1, 12, 10)
screen:expect([[
@ -3730,6 +3730,6 @@ describe('ext_multigrid', function()
{1:~ }|
{1:~ }|
]])
eq(1, meths.get_option('cmdheight'))
eq(1, meths.get_option_value('cmdheight', {}))
end)
end)

View File

@ -27,7 +27,7 @@ describe('quickfix selection highlight', function()
[12] = {foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia},
})
meths.set_option('errorformat', '%m %l')
meths.set_option_value('errorformat', '%m %l', {})
command('syntax on')
command('highlight Search guibg=Green')

View File

@ -828,7 +828,7 @@ local function screen_tests(linegrid)
command([[autocmd VimResized * redrawtabline]])
command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]])
command([[autocmd VimResized * let g:echospace = v:echospace]])
meths.set_option('showtabline', 2)
meths.set_option_value('showtabline', 2, {})
screen:expect([[
{2: + [No Name] }{3: }|
resiz^e |
@ -1056,8 +1056,8 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function()
clear()
local screen = Screen.new(100, 100)
screen:attach()
eq(100, meths.get_option('lines'))
eq(99, meths.get_option('window'))
eq(100, meths.get_option_value('lines', {}))
eq(99, meths.get_option_value('window', {}))
eq(99, meths.win_get_height(0))
feed('1000o<Esc>')
eq(903, funcs.line('w0'))
@ -1071,8 +1071,8 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function()
eq(903, funcs.line('w0'))
feed('G')
screen:try_resize(50, 50)
eq(50, meths.get_option('lines'))
eq(49, meths.get_option('window'))
eq(50, meths.get_option_value('lines', {}))
eq(49, meths.get_option_value('window', {}))
eq(49, meths.win_get_height(0))
eq(953, funcs.line('w0'))
feed('<C-B>')

View File

@ -34,7 +34,7 @@ for _, model in ipairs(mousemodels) do
end)
it('works', function()
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
meths.input_mouse('left', 'press', '', 0, 6, 17)
eq('0 1 l', eval("g:testvar"))
meths.input_mouse('left', 'press', '', 0, 6, 17)
@ -54,7 +54,7 @@ for _, model in ipairs(mousemodels) do
end)
it('works for winbar', function()
meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
meths.input_mouse('left', 'press', '', 0, 0, 17)
eq('0 1 l', eval("g:testvar"))
meths.input_mouse('right', 'press', '', 0, 0, 17)
@ -72,8 +72,8 @@ for _, model in ipairs(mousemodels) do
it('works when there are multiple windows', function()
command('split')
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
meths.input_mouse('left', 'press', '', 0, 0, 17)
eq('0 1 l', eval("g:testvar"))
meths.input_mouse('right', 'press', '', 0, 4, 17)
@ -90,23 +90,23 @@ for _, model in ipairs(mousemodels) do
vim.g.testvar = string.format("%d %d %s", minwid, clicks, button)
end
]])
meths.set_option('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T')
meths.set_option_value('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T', {})
meths.input_mouse('left', 'press', '', 0, 6, 17)
eq('0 1 l', eval("g:testvar"))
end)
it('ignores unsupported click items', function()
command('tabnew | tabprevious')
meths.set_option('statusline', '%2TNot clicky stuff%T')
meths.set_option_value('statusline', '%2TNot clicky stuff%T', {})
meths.input_mouse('left', 'press', '', 0, 6, 0)
eq(1, meths.get_current_tabpage().id)
meths.set_option('statusline', '%2XNot clicky stuff%X')
meths.set_option_value('statusline', '%2XNot clicky stuff%X', {})
meths.input_mouse('left', 'press', '', 0, 6, 0)
eq(2, #meths.list_tabpages())
end)
it("right click works when statusline isn't focused #18994", function()
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
meths.input_mouse('right', 'press', '', 0, 6, 17)
eq('0 1 r', eval("g:testvar"))
meths.input_mouse('right', 'press', '', 0, 6, 17)
@ -114,7 +114,7 @@ for _, model in ipairs(mousemodels) do
end)
it("works with modifiers #18994", function()
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {})
-- Note: alternate between left and right mouse buttons to avoid triggering multiclicks
meths.input_mouse('left', 'press', 'S', 0, 6, 17)
eq('0 1 l(s )', eval("g:testvar"))
@ -143,7 +143,7 @@ for _, model in ipairs(mousemodels) do
it("works for global statusline with vertical splits #19186", function()
command('set laststatus=3')
meths.set_option('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T')
meths.set_option_value('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {})
command('vsplit')
screen:expect([[
^ |
@ -394,38 +394,38 @@ describe('global statusline', function()
end)
it('win_move_statusline() can reduce cmdheight to 1', function()
eq(1, meths.get_option('cmdheight'))
eq(1, meths.get_option_value('cmdheight', {}))
funcs.win_move_statusline(0, -1)
eq(2, meths.get_option('cmdheight'))
eq(2, meths.get_option_value('cmdheight', {}))
funcs.win_move_statusline(0, -1)
eq(3, meths.get_option('cmdheight'))
eq(3, meths.get_option_value('cmdheight', {}))
funcs.win_move_statusline(0, 1)
eq(2, meths.get_option('cmdheight'))
eq(2, meths.get_option_value('cmdheight', {}))
funcs.win_move_statusline(0, 1)
eq(1, meths.get_option('cmdheight'))
eq(1, meths.get_option_value('cmdheight', {}))
end)
it('mouse dragging can reduce cmdheight to 1', function()
command('set mouse=a')
meths.input_mouse('left', 'press', '', 0, 14, 10)
eq(1, meths.get_option('cmdheight'))
eq(1, meths.get_option_value('cmdheight', {}))
meths.input_mouse('left', 'drag', '', 0, 13, 10)
eq(2, meths.get_option('cmdheight'))
eq(2, meths.get_option_value('cmdheight', {}))
meths.input_mouse('left', 'drag', '', 0, 12, 10)
eq(3, meths.get_option('cmdheight'))
eq(3, meths.get_option_value('cmdheight', {}))
meths.input_mouse('left', 'drag', '', 0, 13, 10)
eq(2, meths.get_option('cmdheight'))
eq(2, meths.get_option_value('cmdheight', {}))
meths.input_mouse('left', 'drag', '', 0, 14, 10)
eq(1, meths.get_option('cmdheight'))
eq(1, meths.get_option_value('cmdheight', {}))
meths.input_mouse('left', 'drag', '', 0, 15, 10)
eq(1, meths.get_option('cmdheight'))
eq(1, meths.get_option_value('cmdheight', {}))
meths.input_mouse('left', 'drag', '', 0, 14, 10)
eq(1, meths.get_option('cmdheight'))
eq(1, meths.get_option_value('cmdheight', {}))
end)
it('cmdline row is correct after setting cmdheight #20514', function()
command('botright split test/functional/fixtures/bigfile.txt')
meths.set_option('cmdheight', 1)
meths.set_option_value('cmdheight', 1, {})
feed('L')
screen:expect([[
|
@ -464,7 +464,7 @@ describe('global statusline', function()
{2:test/functional/fixtures/bigfile.txt 8,1 0%}|
|
]])
meths.set_option('showtabline', 2)
meths.set_option_value('showtabline', 2, {})
screen:expect([[
{3: }{5:2}{3: t/f/f/bigfile.txt }{4: }|
|
@ -483,7 +483,7 @@ describe('global statusline', function()
{2:test/functional/fixtures/bigfile.txt 8,1 0%}|
|
]])
meths.set_option('cmdheight', 0)
meths.set_option_value('cmdheight', 0, {})
screen:expect([[
{3: }{5:2}{3: t/f/f/bigfile.txt }{4: }|
|
@ -502,7 +502,7 @@ describe('global statusline', function()
^0007;<control>;Cc;0;BN;;;;;N;BELL;;;; |
{2:test/functional/fixtures/bigfile.txt 8,1 0%}|
]])
meths.set_option('cmdheight', 1)
meths.set_option_value('cmdheight', 1, {})
screen:expect([[
{3: }{5:2}{3: t/f/f/bigfile.txt }{4: }|
|
@ -526,8 +526,8 @@ end)
it('statusline does not crash if it has Arabic characters #19447', function()
clear()
meths.set_option('statusline', 'غً')
meths.set_option('laststatus', 2)
meths.set_option_value('statusline', 'غً', {})
meths.set_option_value('laststatus', 2, {})
command('redraw!')
assert_alive()
end)

View File

@ -57,18 +57,18 @@ describe('title', function()
end)
end)
it('an RPC call to nvim_buf_set_option in a hidden buffer', function()
meths.buf_set_option(buf2, 'autoindent', true)
it('an RPC call to nvim_set_option_value in a hidden buffer', function()
meths.set_option_value('autoindent', true, { buf = buf2 })
command('redraw!')
screen:expect(function()
eq(expected, screen.title)
end)
end)
it('a Lua callback calling nvim_buf_set_option in a hidden buffer', function()
it('a Lua callback calling nvim_set_option_value in a hidden buffer', function()
exec_lua(string.format([[
vim.schedule(function()
vim.api.nvim_buf_set_option(%d, 'autoindent', true)
vim.api.nvim_set_option_value('autoindent', true, { buf = %d })
end)
]], buf2))
command('redraw!')

View File

@ -367,12 +367,12 @@ describe("'wildmenu'", function()
}
-- Wildcharm? where we are going we aint't no need no wildcharm.
eq(0, meths.get_option'wildcharm')
eq(0, meths.get_option_value('wildcharm', {}))
-- Don't mess the defaults yet (neovim is about backwards compatibility)
eq(9, meths.get_option'wildchar')
eq(9, meths.get_option_value('wildchar', {}))
-- Lol what is cnoremap? Some say it can define mappings.
command 'set wildchar=0'
eq(0, meths.get_option'wildchar')
eq(0, meths.get_option_value('wildchar', {}))
command 'cnoremap <f2> <c-z>'
feed(':syntax <f2>')
@ -481,9 +481,9 @@ describe('command line completion', function()
end)
it('does not leak memory with <S-Tab> with wildmenu and only one match #19874', function()
meths.set_option('wildmenu', true)
meths.set_option('wildmode', 'full')
meths.set_option('wildoptions', 'pum')
meths.set_option_value('wildmenu', true, {})
meths.set_option_value('wildmode', 'full', {})
meths.set_option_value('wildoptions', 'pum', {})
feed(':sign unpla<S-Tab>')
screen:expect([[
@ -505,8 +505,8 @@ describe('command line completion', function()
end)
it('does not show matches with <S-Tab> without wildmenu with wildmode=full', function()
meths.set_option('wildmenu', false)
meths.set_option('wildmode', 'full')
meths.set_option_value('wildmenu', false, {})
meths.set_option_value('wildmode', 'full', {})
feed(':sign <S-Tab>')
screen:expect([[
@ -519,8 +519,8 @@ describe('command line completion', function()
end)
it('shows matches with <S-Tab> without wildmenu with wildmode=list', function()
meths.set_option('wildmenu', false)
meths.set_option('wildmode', 'list')
meths.set_option_value('wildmenu', false, {})
meths.set_option_value('wildmode', 'list', {})
feed(':sign <S-Tab>')
screen:expect([[

View File

@ -31,7 +31,7 @@ describe('winbar', function()
[10] = {background = Screen.colors.LightGrey, underline = true},
[11] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta},
})
meths.set_option('winbar', 'Set Up The Bars')
meths.set_option_value('winbar', 'Set Up The Bars', {})
end)
it('works', function()
@ -206,7 +206,7 @@ describe('winbar', function()
insert [[
just some
random text]]
meths.set_option('winbar', 'Hello, I am a ruler: %l,%c')
meths.set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {})
screen:expect{grid=[[
{1:Hello, I am a ruler: 2,11 }|
just some |
@ -450,7 +450,7 @@ describe('winbar', function()
|
|
]])
eq(3, meths.get_option('cmdheight'))
eq(3, meths.get_option_value('cmdheight', {}))
meths.input_mouse('left', 'drag', '', 1, 11, 10)
screen:expect([[
@ -468,7 +468,7 @@ describe('winbar', function()
{2:[No Name] }|
|
]])
eq(1, meths.get_option('cmdheight'))
eq(1, meths.get_option_value('cmdheight', {}))
end)
it('properly equalizes window height for window-local value', function()

View File

@ -32,8 +32,8 @@ describe('eval-API', function()
local err = exc_exec('call nvim_get_current_buf("foo")')
eq('Vim(call):E118: Too many arguments for function: nvim_get_current_buf', err)
err = exc_exec('call nvim_set_option("hlsearch")')
eq('Vim(call):E119: Not enough arguments for function: nvim_set_option', err)
err = exc_exec('call nvim_set_option_value("hlsearch")')
eq('Vim(call):E119: Not enough arguments for function: nvim_set_option_value', err)
err = exc_exec('call nvim_buf_set_lines(1, 0, -1, [], ["list"])')
eq('Vim(call):E5555: API call: Wrong type for argument 4 when calling nvim_buf_set_lines, expecting Boolean', err)

View File

@ -9,7 +9,6 @@ local meths = helpers.meths
local command = helpers.command
local exc_exec = helpers.exc_exec
local bufmeths = helpers.bufmeths
local winmeths = helpers.winmeths
local curbufmeths = helpers.curbufmeths
local curwinmeths = helpers.curwinmeths
local curtabmeths = helpers.curtabmeths
@ -189,7 +188,7 @@ describe('getbufline() function', function()
eq({}, funcs.getbufline(1, -1, 9999))
end)
it('returns expected lines', function()
meths.set_option('hidden', true)
meths.set_option_value('hidden', true, {})
command('file ' .. fname)
curbufmeths.set_lines(0, 1, false, {'foo\0', '\0bar', 'baz'})
command('edit ' .. fname2)
@ -269,24 +268,25 @@ describe('setbufvar() function', function()
end)
it('may set options, including window-local and global values', function()
local buf1 = meths.get_current_buf()
eq(false, curwinmeths.get_option('number'))
eq(false, meths.get_option_value('number', {win=0}))
command('split')
command('new')
eq(2, bufmeths.get_number(curwinmeths.get_buf()))
funcs.setbufvar(1, '&number', true)
local windows = curtabmeths.list_wins()
eq(false, winmeths.get_option(windows[1], 'number'))
eq(true, winmeths.get_option(windows[2], 'number'))
eq(false, winmeths.get_option(windows[3], 'number'))
eq(false, winmeths.get_option(meths.get_current_win(), 'number'))
eq(false, meths.get_option_value('number', {win=windows[1].id}))
eq(true, meths.get_option_value('number', {win=windows[2].id}))
eq(false, meths.get_option_value('number', {win=windows[3].id}))
eq(false, meths.get_option_value('number', {win=meths.get_current_win().id}))
eq(true, meths.get_option('hidden'))
eq(true, meths.get_option_value('hidden', {}))
funcs.setbufvar(1, '&hidden', 0)
eq(false, meths.get_option('hidden'))
eq(false, meths.get_option_value('hidden', {}))
eq(false, bufmeths.get_option(buf1, 'autoindent'))
eq(false, meths.get_option_value('autoindent', {buf=buf1.id}))
funcs.setbufvar(1, '&autoindent', true)
eq(true, bufmeths.get_option(buf1, 'autoindent'))
eq(true, meths.get_option_value('autoindent', {buf=buf1.id}))
eq('Vim(call):E355: Unknown option: xxx',
exc_exec('call setbufvar(1, "&xxx", 0)'))
end)

View File

@ -452,8 +452,8 @@ end)
describe('confirm()', function()
-- oldtest: Test_confirm()
it('works', function()
meths.set_option('more', false) -- Avoid hit-enter prompt
meths.set_option('laststatus', 2)
meths.set_option_value('more', false, {}) -- Avoid hit-enter prompt
meths.set_option_value('laststatus', 2, {})
-- screen:expect() calls are needed to avoid feeding input too early
screen:expect({any = '%[No Name%]'})

View File

@ -754,7 +754,7 @@ describe('json_encode() function', function()
end)
it('ignores improper values in &isprint', function()
meths.set_option('isprint', '1')
meths.set_option_value('isprint', '1', {})
eq(1, eval('"\1" =~# "\\\\p"'))
eq('"\\u0001"', funcs.json_encode('\1'))
end)

View File

@ -210,8 +210,8 @@ describe('system()', function()
end)
it('prints verbose information', function()
nvim('set_option', 'shell', 'fake_shell')
nvim('set_option', 'shellcmdflag', 'cmdflag')
nvim('set_option_value', 'shell', 'fake_shell', {})
nvim('set_option_value', 'shellcmdflag', 'cmdflag', {})
screen:try_resize(72, 14)
feed(':4verbose echo system("echo hi")<cr>')