aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2022-12-19 16:37:45 +0000
committerFamiu Haque <famiuhaque@proton.me>2023-05-21 15:14:01 +0600
commit1fe1bb084d0099fc4f9bfdc11189485d0f74b75a (patch)
treeec823587a4c7ea6991330f6db362846e0fb7bc21
parente3e6fadfd82861471c32fdcabe00bbef3de84563 (diff)
downloadrneovim-1fe1bb084d0099fc4f9bfdc11189485d0f74b75a.tar.gz
rneovim-1fe1bb084d0099fc4f9bfdc11189485d0f74b75a.tar.bz2
rneovim-1fe1bb084d0099fc4f9bfdc11189485d0f74b75a.zip
refactor(options): deprecate nvim[_buf|_win]_[gs]et_option
Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: famiu <famiuhaque@protonmail.com>
-rw-r--r--runtime/doc/api.txt56
-rw-r--r--runtime/doc/deprecated.txt6
-rw-r--r--runtime/doc/lsp.txt4
-rw-r--r--runtime/doc/lua.txt2
-rw-r--r--runtime/doc/news.txt10
-rw-r--r--runtime/lua/vim/lsp.lua16
-rw-r--r--runtime/lua/vim/lsp/handlers.lua2
-rw-r--r--runtime/lua/vim/lsp/util.lua30
-rw-r--r--runtime/pack/dist/opt/termdebug/plugin/termdebug.vim6
-rw-r--r--src/nvim/api/deprecated.c220
-rw-r--r--src/nvim/api/options.c216
-rw-r--r--src/nvim/api/options.h1
-rw-r--r--test/functional/api/buffer_spec.lua24
-rw-r--r--test/functional/api/extmark_spec.lua4
-rw-r--r--test/functional/api/highlight_spec.lua4
-rw-r--r--test/functional/api/vim_spec.lua88
-rw-r--r--test/functional/api/window_spec.lua26
-rw-r--r--test/functional/autocmd/autocmd_spec.lua2
-rw-r--r--test/functional/autocmd/cursorhold_spec.lua6
-rw-r--r--test/functional/autocmd/termxx_spec.lua14
-rw-r--r--test/functional/core/spellfile_spec.lua20
-rw-r--r--test/functional/core/startup_spec.lua6
-rw-r--r--test/functional/editor/K_spec.lua2
-rw-r--r--test/functional/editor/completion_spec.lua2
-rw-r--r--test/functional/editor/mode_cmdline_spec.lua2
-rw-r--r--test/functional/ex_cmds/append_spec.lua3
-rw-r--r--test/functional/ex_cmds/ls_spec.lua2
-rw-r--r--test/functional/ex_cmds/make_spec.lua4
-rw-r--r--test/functional/ex_cmds/map_spec.lua2
-rw-r--r--test/functional/ex_cmds/mksession_spec.lua14
-rw-r--r--test/functional/ex_cmds/source_spec.lua2
-rw-r--r--test/functional/ex_cmds/verbose_spec.lua4
-rw-r--r--test/functional/ex_cmds/write_spec.lua8
-rw-r--r--test/functional/legacy/012_directory_spec.lua13
-rw-r--r--test/functional/legacy/autocmd_option_spec.lua12
-rw-r--r--test/functional/legacy/buffer_spec.lua2
-rw-r--r--test/functional/legacy/cmdline_spec.lua14
-rw-r--r--test/functional/legacy/filechanged_spec.lua4
-rw-r--r--test/functional/legacy/messages_spec.lua6
-rw-r--r--test/functional/legacy/vimscript_spec.lua2
-rw-r--r--test/functional/lua/buffer_updates_spec.lua12
-rw-r--r--test/functional/lua/command_line_completion_spec.lua8
-rw-r--r--test/functional/lua/filetype_spec.lua2
-rw-r--r--test/functional/lua/inspector_spec.lua6
-rw-r--r--test/functional/lua/luaeval_spec.lua4
-rw-r--r--test/functional/lua/overrides_spec.lua2
-rw-r--r--test/functional/lua/secure_spec.lua4
-rw-r--r--test/functional/lua/vim_spec.lua60
-rw-r--r--test/functional/options/defaults_spec.lua64
-rw-r--r--test/functional/options/num_options_spec.lua22
-rw-r--r--test/functional/plugin/editorconfig_spec.lua3
-rw-r--r--test/functional/plugin/lsp/incremental_sync_spec.lua2
-rw-r--r--test/functional/plugin/lsp_spec.lua20
-rw-r--r--test/functional/plugin/shada_spec.lua30
-rw-r--r--test/functional/provider/perl_spec.lua4
-rw-r--r--test/functional/provider/ruby_spec.lua3
-rw-r--r--test/functional/shada/buffers_spec.lua8
-rw-r--r--test/functional/shada/history_spec.lua8
-rw-r--r--test/functional/shada/shada_spec.lua34
-rw-r--r--test/functional/terminal/buffer_spec.lua2
-rw-r--r--test/functional/terminal/edit_spec.lua6
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua10
-rw-r--r--test/functional/terminal/mouse_spec.lua4
-rw-r--r--test/functional/terminal/scrollback_spec.lua46
-rw-r--r--test/functional/terminal/tui_spec.lua10
-rw-r--r--test/functional/terminal/window_split_tab_spec.lua4
-rw-r--r--test/functional/ui/cmdline_highlight_spec.lua2
-rw-r--r--test/functional/ui/cursor_spec.lua8
-rw-r--r--test/functional/ui/decorations_spec.lua6
-rw-r--r--test/functional/ui/float_spec.lua52
-rw-r--r--test/functional/ui/fold_spec.lua4
-rw-r--r--test/functional/ui/inccommand_spec.lua23
-rw-r--r--test/functional/ui/inccommand_user_spec.lua2
-rw-r--r--test/functional/ui/messages_spec.lua2
-rw-r--r--test/functional/ui/mouse_spec.lua26
-rw-r--r--test/functional/ui/multigrid_spec.lua6
-rw-r--r--test/functional/ui/quickfix_spec.lua2
-rw-r--r--test/functional/ui/screen_basic_spec.lua10
-rw-r--r--test/functional/ui/statusline_spec.lua56
-rw-r--r--test/functional/ui/title_spec.lua8
-rw-r--r--test/functional/ui/wildmode_spec.lua20
-rw-r--r--test/functional/ui/winbar_spec.lua8
-rw-r--r--test/functional/vimscript/api_functions_spec.lua4
-rw-r--r--test/functional/vimscript/buf_functions_spec.lua22
-rw-r--r--test/functional/vimscript/input_spec.lua4
-rw-r--r--test/functional/vimscript/json_functions_spec.lua2
-rw-r--r--test/functional/vimscript/system_spec.lua4
87 files changed, 725 insertions, 785 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 1f65c3ac01..e7cda59906 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -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*
diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt
index 3150190a8b..9d4a7324bf 100644
--- a/runtime/doc/deprecated.txt
+++ b/runtime/doc/deprecated.txt
@@ -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.
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index ca1a9a414d..98a0801013 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -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
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index c6568b073d..ad9cb69ae0 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -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.
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 11ef26165f..9f6ab2ddd0 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -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:
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 92f5653158..2e6ca7a0ac 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -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:
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index 71bef43bc1..8e926c4644 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -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
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 8274361f6d..9fffc845b1 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -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)
els