diff options
author | Ilia Choly <ilia.choly@gmail.com> | 2024-06-04 09:06:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-04 06:06:02 -0700 |
commit | 8cbb1f20e557461c8417583a7f69d53aaaef920b (patch) | |
tree | 7b24c7e171b712d77fa74ebc13e8541dd663393f | |
parent | 61025c9e7aa41dae11422162a54cc7696f7e783e (diff) | |
download | rneovim-8cbb1f20e557461c8417583a7f69d53aaaef920b.tar.gz rneovim-8cbb1f20e557461c8417583a7f69d53aaaef920b.tar.bz2 rneovim-8cbb1f20e557461c8417583a7f69d53aaaef920b.zip |
refactor(lua): use tuple syntax everywhere #29111
24 files changed, 53 insertions, 54 deletions
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index 2438c48154..c7bb02e7f1 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -393,11 +393,11 @@ Lua module: vim.diagnostic *diagnostic-api* by {count} diagnostics, while a negative integer moves backward by {count} diagnostics. Mutually exclusive with {diagnostic}. - • {pos}? (`{[1]:integer,[2]:integer}`) Cursor position as a - `(row, col)` tuple. See |nvim_win_get_cursor()|. Used - to find the nearest diagnostic when {count} is used. - Only used when {count} is non-nil. Default is the - current cursor position. + • {pos}? (`[integer,integer]`) Cursor position as a `(row, col)` + tuple. See |nvim_win_get_cursor()|. Used to find the + nearest diagnostic when {count} is used. Only used when + {count} is non-nil. Default is the current cursor + position. • {wrap}? (`boolean`, default: `true`) Whether to loop around file or not. Similar to 'wrapscan'. • {severity}? (`vim.diagnostic.SeverityFilter`) See @@ -467,18 +467,18 @@ Lua module: vim.diagnostic *diagnostic-api* current cursor position (`cursor`). Shorthand versions are also accepted (`c` for `cursor`, `l` for `line`, `b` for `buffer`). - • {pos}? (`integer|{[1]:integer,[2]:integer}`) If {scope} is - "line" or "cursor", use this position rather than - the cursor position. If a number, interpreted as a - line number; otherwise, a (row, col) tuple. + • {pos}? (`integer|[integer,integer]`) If {scope} is "line" + or "cursor", use this position rather than the + cursor position. If a number, interpreted as a line + number; otherwise, a (row, col) tuple. • {severity_sort}? (`boolean|{reverse?:boolean}`, default: `false`) Sort diagnostics by severity. Overrides the setting from |vim.diagnostic.config()|. • {severity}? (`vim.diagnostic.SeverityFilter`) See |diagnostic-severity|. Overrides the setting from |vim.diagnostic.config()|. - • {header}? (`string|{[1]:string,[2]:any}`) String to use as the - header for the floating window. If a table, it is + • {header}? (`string|[string,any]`) String to use as the header + for the floating window. If a table, it is interpreted as a `[text, hl_group]` tuple. Overrides the setting from |vim.diagnostic.config()|. • {source}? (`boolean|'if_many'`) Include the diagnostic source @@ -591,8 +591,7 @@ Lua module: vim.diagnostic *diagnostic-api* < • {hl_mode}? (`'replace'|'combine'|'blend'`) See |nvim_buf_set_extmark()|. - • {virt_text}? (`{[1]:string,[2]:any}[]`) See - |nvim_buf_set_extmark()|. + • {virt_text}? (`[string,any][]`) See |nvim_buf_set_extmark()|. • {virt_text_pos}? (`'eol'|'overlay'|'right_align'|'inline'`) See |nvim_buf_set_extmark()|. • {virt_text_win_col}? (`integer`) See |nvim_buf_set_extmark()|. diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 36d6e0d41e..e2fcac1bda 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -834,8 +834,8 @@ vim.spell.check({str}) *vim.spell.check()* • {str} (`string`) Return: ~ - (`{[1]: string, [2]: 'bad'|'rare'|'local'|'caps', [3]: integer}[]`) - List of tuples with three items: + (`[string, 'bad'|'rare'|'local'|'caps', integer][]`) List of tuples + with three items: • The badly spelled word. • The type of the spelling error: "bad" spelling mistake "rare" rare word "local" word only valid in another region "caps" word should diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 0b84bb60d4..25b070b310 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -764,9 +764,9 @@ get_node({opts}) *vim.treesitter.get_node()* • {opts} (`table?`) Optional keyword arguments: • {bufnr} (`integer?`) Buffer number (nil or 0 for current buffer) - • {pos} (`{ [1]: integer, [2]: integer }?`) 0-indexed (row, - col) tuple. Defaults to cursor position in the current - window. Required if {bufnr} is not the current buffer + • {pos} (`[integer, integer]?`) 0-indexed (row, col) tuple. + Defaults to cursor position in the current window. Required + if {bufnr} is not the current buffer • {lang} (`string?`) Parser language. (default: from buffer filetype) • {ignore_injections} (`boolean?`) Ignore injected languages diff --git a/runtime/lua/tohtml.lua b/runtime/lua/tohtml.lua index 120247ed4e..a67e1c69e2 100644 --- a/runtime/lua/tohtml.lua +++ b/runtime/lua/tohtml.lua @@ -46,7 +46,7 @@ --- @field [integer] vim.tohtml.line (integer: (1-index, exclusive)) --- @class (private) vim.tohtml.line ---- @field virt_lines {[integer]:{[1]:string,[2]:integer}[]} +--- @field virt_lines {[integer]:[string,integer][]} --- @field pre_text string[][] --- @field hide? boolean --- @field [integer] vim.tohtml.cell? (integer: (1-index, exclusive)) @@ -481,7 +481,7 @@ local function styletable_treesitter(state) end --- @param state vim.tohtml.state ---- @param extmark {[1]:integer,[2]:integer,[3]:integer,[4]:vim.api.keyset.set_extmark|any} +--- @param extmark [integer, integer, integer, vim.api.keyset.set_extmark|any] --- @param namespaces table<integer,string> local function _styletable_extmarks_highlight(state, extmark, namespaces) if not extmark[4].hl_group then @@ -503,7 +503,7 @@ local function _styletable_extmarks_highlight(state, extmark, namespaces) end --- @param state vim.tohtml.state ---- @param extmark {[1]:integer,[2]:integer,[3]:integer,[4]:vim.api.keyset.set_extmark|any} +--- @param extmark [integer, integer, integer, vim.api.keyset.set_extmark|any] --- @param namespaces table<integer,string> local function _styletable_extmarks_virt_text(state, extmark, namespaces) if not extmark[4].virt_text then @@ -559,7 +559,7 @@ local function _styletable_extmarks_virt_text(state, extmark, namespaces) end --- @param state vim.tohtml.state ---- @param extmark {[1]:integer,[2]:integer,[3]:integer,[4]:vim.api.keyset.set_extmark|any} +--- @param extmark [integer, integer, integer, vim.api.keyset.set_extmark|any] local function _styletable_extmarks_virt_lines(state, extmark) ---TODO(altermo) if the fold start is equal to virt_line start then the fold hides the virt_line if not extmark[4].virt_lines then @@ -580,7 +580,7 @@ local function _styletable_extmarks_virt_lines(state, extmark) end --- @param state vim.tohtml.state ---- @param extmark {[1]:integer,[2]:integer,[3]:integer,[4]:vim.api.keyset.set_extmark|any} +--- @param extmark [integer, integer, integer, vim.api.keyset.set_extmark|any] local function _styletable_extmarks_conceal(state, extmark) if not extmark[4].conceal or state.opt.conceallevel == 0 then return @@ -648,7 +648,7 @@ local function styletable_conceal(state) local bufnr = state.bufnr vim.api.nvim_buf_call(bufnr, function() for row = 1, state.buflen do - --- @type table<integer,{[1]:integer,[2]:integer,[3]:string}> + --- @type table<integer,[integer,integer,string]> local conceals = {} local line_len_exclusive = #vim.fn.getline(row) + 1 for col = 1, line_len_exclusive do diff --git a/runtime/lua/vim/_meta/api_keysets_extra.lua b/runtime/lua/vim/_meta/api_keysets_extra.lua index 76b56b04e7..e1f12868d0 100644 --- a/runtime/lua/vim/_meta/api_keysets_extra.lua +++ b/runtime/lua/vim/_meta/api_keysets_extra.lua @@ -26,13 +26,13 @@ error('Cannot require a meta file') --- @field url? boolean --- @field hl_mode? string --- ---- @field virt_text? {[1]: string, [2]: string}[] +--- @field virt_text? [string, string][] --- @field virt_text_hide? boolean --- @field virt_text_repeat_linebreak? boolean --- @field virt_text_win_col? integer --- @field virt_text_pos? string --- ---- @field virt_lines? {[1]: string, [2]: string}[][] +--- @field virt_lines? [string, string][][] --- @field virt_lines_above? boolean --- @field virt_lines_leftcol? boolean --- diff --git a/runtime/lua/vim/_meta/builtin_types.lua b/runtime/lua/vim/_meta/builtin_types.lua index 9f0d2e7038..53dd8d95e9 100644 --- a/runtime/lua/vim/_meta/builtin_types.lua +++ b/runtime/lua/vim/_meta/builtin_types.lua @@ -25,7 +25,7 @@ --- @field variables table<string,any> --- @field windows integer[] ---- @alias vim.fn.getjumplist.ret {[1]: vim.fn.getjumplist.ret.item[], [2]: integer} +--- @alias vim.fn.getjumplist.ret [vim.fn.getjumplist.ret.item[], integer] --- @class vim.fn.getjumplist.ret.item --- @field bufnr integer diff --git a/runtime/lua/vim/_meta/spell.lua b/runtime/lua/vim/_meta/spell.lua index c636db3b53..b4e3bf6ca4 100644 --- a/runtime/lua/vim/_meta/spell.lua +++ b/runtime/lua/vim/_meta/spell.lua @@ -20,7 +20,7 @@ --- ``` --- --- @param str string ---- @return {[1]: string, [2]: 'bad'|'rare'|'local'|'caps', [3]: integer}[] +--- @return [string, 'bad'|'rare'|'local'|'caps', integer][] --- List of tuples with three items: --- - The badly spelled word. --- - The type of the spelling error: diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 84bb26a135..a1600e1cb5 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -9796,7 +9796,7 @@ function vim.fn.synIDtrans(synID) end --- --- @param lnum integer --- @param col integer ---- @return {[1]: integer, [2]: string, [3]: integer} +--- @return [integer, string, integer] function vim.fn.synconcealed(lnum, col) end --- Return a |List|, which is the stack of syntax items at the diff --git a/runtime/lua/vim/deprecated/health.lua b/runtime/lua/vim/deprecated/health.lua index 64a755b248..eed889d90a 100644 --- a/runtime/lua/vim/deprecated/health.lua +++ b/runtime/lua/vim/deprecated/health.lua @@ -1,7 +1,7 @@ local M = {} local health = vim.health -local deprecated = {} ---@type {[1]: string, [2]: table, [3]: string}[] +local deprecated = {} ---@type [string, table, string][] function M.check() if next(deprecated) == nil then diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index dca7698356..c6649ae09b 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -108,7 +108,7 @@ local M = {} --- If {scope} is "line" or "cursor", use this position rather than the cursor --- position. If a number, interpreted as a line number; otherwise, a --- (row, col) tuple. ---- @field pos? integer|{[1]:integer,[2]:integer} +--- @field pos? integer|[integer,integer] --- --- Sort diagnostics by severity. --- Overrides the setting from |vim.diagnostic.config()|. @@ -122,7 +122,7 @@ local M = {} --- String to use as the header for the floating window. If a table, it is --- interpreted as a `[text, hl_group]` tuple. --- Overrides the setting from |vim.diagnostic.config()|. ---- @field header? string|{[1]:string,[2]:any} +--- @field header? string|[string,any] --- --- Include the diagnostic source in the message. --- Use "if_many" to only show sources if there is more than one source of @@ -203,7 +203,7 @@ local M = {} --- @field hl_mode? 'replace'|'combine'|'blend' --- --- See |nvim_buf_set_extmark()|. ---- @field virt_text? {[1]:string,[2]:any}[] +--- @field virt_text? [string,any][] --- --- See |nvim_buf_set_extmark()|. --- @field virt_text_pos? 'eol'|'overlay'|'right_align'|'inline' @@ -1252,7 +1252,7 @@ end --- Cursor position as a `(row, col)` tuple. See |nvim_win_get_cursor()|. Used --- to find the nearest diagnostic when {count} is used. Only used when {count} --- is non-nil. Default is the current cursor position. ---- @field pos? {[1]:integer,[2]:integer} +--- @field pos? [integer,integer] --- --- Whether to loop around file or not. Similar to 'wrapscan'. --- (default: `true`) diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index c8f9bcfd84..cc2fbe0cec 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -4,7 +4,7 @@ local fn = vim.fn local M = {} --- @alias vim.filetype.mapfn fun(path:string,bufnr:integer, ...):string?, fun(b:integer)? ---- @alias vim.filetype.maptbl {[1]:string|vim.filetype.mapfn, [2]:{priority:integer}} +--- @alias vim.filetype.maptbl [string|vim.filetype.mapfn, {priority:integer}] --- @alias vim.filetype.mapping.value string|vim.filetype.mapfn|vim.filetype.maptbl --- @alias vim.filetype.mapping table<string,vim.filetype.mapping.value> diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua index c9326a0681..4b7deabf41 100644 --- a/runtime/lua/vim/lsp/completion.lua +++ b/runtime/lua/vim/lsp/completion.lua @@ -30,7 +30,7 @@ local buf_handles = {} --- @nodoc --- @class vim.lsp.completion.Context local Context = { - cursor = nil, --- @type { [1]: integer, [2]: integer }? + cursor = nil, --- @type [integer, integer]? last_request_time = nil, --- @type integer? pending_requests = {}, --- @type function[] isIncomplete = false, diff --git a/runtime/lua/vim/lsp/inlay_hint.lua b/runtime/lua/vim/lsp/inlay_hint.lua index 78f309abf7..8fd4ceefd2 100644 --- a/runtime/lua/vim/lsp/inlay_hint.lua +++ b/runtime/lua/vim/lsp/inlay_hint.lua @@ -348,7 +348,7 @@ api.nvim_set_decoration_provider(namespace, { text = text .. part.value end end - local vt = {} --- @type {[1]: string, [2]: string?}[] + local vt = {} --- @type [string, string?][] if hint.paddingLeft then vt[#vt + 1] = { ' ' } end diff --git a/runtime/lua/vim/provider/health.lua b/runtime/lua/vim/provider/health.lua index fa2c452268..860f839f23 100644 --- a/runtime/lua/vim/provider/health.lua +++ b/runtime/lua/vim/provider/health.lua @@ -353,7 +353,7 @@ end --- their respective paths. If either of those is invalid, return two empty --- strings, effectively ignoring pyenv. --- ---- @return {[1]: string, [2]: string} +--- @return [string, string] local function check_for_pyenv() local pyenv_path = vim.fn.resolve(vim.fn.exepath('pyenv')) diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 0ec79e1dc7..9d54a80144 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -789,7 +789,7 @@ do } --- @nodoc - --- @class vim.validate.Spec {[1]: any, [2]: string|string[], [3]: boolean } + --- @class vim.validate.Spec [any, string|string[], boolean] --- @field [1] any Argument value --- @field [2] string|string[]|fun(v:any):boolean, string? Type name, or callable --- @field [3]? boolean diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua index db544c1ab1..e36aacfd94 100644 --- a/runtime/lua/vim/treesitter.lua +++ b/runtime/lua/vim/treesitter.lua @@ -335,7 +335,7 @@ end --- --- 0-indexed (row, col) tuple. Defaults to cursor position in the --- current window. Required if {bufnr} is not the current buffer ---- @field pos { [1]: integer, [2]: integer }? +--- @field pos [integer, integer]? --- --- Parser language. (default: from buffer filetype) --- @field lang string? diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua index ca8cf85eda..56608bbf14 100644 --- a/runtime/lua/vim/treesitter/dev.lua +++ b/runtime/lua/vim/treesitter/dev.lua @@ -174,7 +174,7 @@ end --- @param source_buf integer --- @param inspect_buf integer --- @param inspect_win integer ---- @param pos? { [1]: integer, [2]: integer } +--- @param pos? [integer, integer] local function set_inspector_cursor(treeview, lang, source_buf, inspect_buf, inspect_win, pos) api.nvim_buf_clear_namespace(inspect_buf, treeview.ns, 0, -1) diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua index f1bba5c0a2..76092f8b39 100755 --- a/scripts/gen_eval_files.lua +++ b/scripts/gen_eval_files.lua @@ -6,7 +6,7 @@ local DEP_API_METADATA = 'build/funcs_metadata.mpack' --- @class vim.api.metadata --- @field name string ---- @field parameters {[1]:string,[2]:string}[] +--- @field parameters [string,string][] --- @field return_type string --- @field deprecated_since integer --- @field eval boolean @@ -149,7 +149,7 @@ local function api_type(t) end --- @param f string ---- @param params {[1]:string,[2]:string}[]|true +--- @param params [string,string][]|true --- @return string local function render_fun_sig(f, params) local param_str --- @type string @@ -158,7 +158,7 @@ local function render_fun_sig(f, params) else param_str = table.concat( vim.tbl_map( - --- @param v {[1]:string,[2]:string} + --- @param v [string,string] --- @return string function(v) return v[1] @@ -178,8 +178,8 @@ end --- Uniquify names --- Fix any names that are lua keywords ---- @param params {[1]:string,[2]:string,[3]:string}[] ---- @return {[1]:string,[2]:string,[3]:string}[] +--- @param params [string,string,string][] +--- @return [string,string,string][] local function process_params(params) local seen = {} --- @type table<string,true> local sfx = 1 @@ -245,7 +245,7 @@ local function get_api_meta() for _, fun in pairs(functions) do local deprecated = fun.deprecated_since ~= nil - local params = {} --- @type {[1]:string,[2]:string}[] + local params = {} --- @type [string,string][] for _, p in ipairs(fun.params) do params[#params + 1] = { p.name, diff --git a/scripts/gen_vimdoc.lua b/scripts/gen_vimdoc.lua index dac6c6f461..507426c8c0 100755 --- a/scripts/gen_vimdoc.lua +++ b/scripts/gen_vimdoc.lua @@ -935,7 +935,7 @@ local function gen_target(cfg) expand_files(cfg.files) - --- @type table<string,{[1]:table<string,nvim.luacats.parser.class>, [2]: nvim.luacats.parser.fun[], [3]: string[]}> + --- @type table<string,[table<string,nvim.luacats.parser.class>, nvim.luacats.parser.fun[], string[]]> local file_results = {} --- @type table<string,nvim.luacats.parser.class> diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index ceaba11f41..3c99ba22c2 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -19,7 +19,7 @@ --- @field returns_desc? string --- @field signature? string --- @field desc? string ---- @field params {[1]:string, [2]:string, [3]:string}[] +--- @field params [string, string, string][] --- @field lua? false Do not render type information --- @field tags? string[] Extra tags --- @field data? string Used by gen_eval.lua @@ -11672,7 +11672,7 @@ M.funcs = { ]=], name = 'synconcealed', params = { { 'lnum', 'integer' }, { 'col', 'integer' } }, - returns = '{[1]: integer, [2]: string, [3]: integer}', + returns = '[integer, string, integer]', signature = 'synconcealed({lnum}, {col})', }, synstack = { diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 0718d965c6..591a6b93df 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -148,7 +148,7 @@ local get_defaults = function(d, n) return value_dumpers[type(d)](d) end ---- @type {[1]:string,[2]:string}[] +--- @type [string,string][] local defines = {} --- @param i integer diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua index d8a3e0acbd..0e81e4fddb 100644 --- a/test/functional/plugin/lsp/completion_spec.lua +++ b/test/functional/plugin/lsp/completion_spec.lua @@ -443,7 +443,7 @@ describe('vim.lsp.completion: protocol', function() end) end - --- @param pos { [1]: integer, [2]: integer } + --- @param pos [integer, integer] local function trigger_at_pos(pos) exec_lua( [[ diff --git a/test/functional/testnvim.lua b/test/functional/testnvim.lua index 6b858e4d69..746c7290ef 100644 --- a/test/functional/testnvim.lua +++ b/test/functional/testnvim.lua @@ -256,7 +256,7 @@ end --- @param notification_cb function? --- @param setup_cb function? --- @param timeout integer ---- @return {[1]: integer, [2]: string} +--- @return [integer, string] function M.run_session(lsession, request_cb, notification_cb, setup_cb, timeout) local on_request --- @type function? local on_notification --- @type function? diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index f8e95f7d88..932ddb070a 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -438,7 +438,7 @@ end --- @field mouse_enabled? boolean --- --- @field win_viewport? table<integer,table<string,integer>> ---- @field float_pos? {[1]:integer,[2]:integer} +--- @field float_pos? [integer,integer] --- @field hl_groups? table<string,integer> --- --- The following keys should be used to expect the state of various ext_ |