diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-04-21 15:19:43 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2024-04-21 17:08:07 +0200 |
commit | d9d890562e43493c999f8a6ff2b848959686f5b6 (patch) | |
tree | e2f751afe697c4e95a37b00b2d75690ca173122d /runtime | |
parent | 032df963bb3fb0b5652e1817e9f4da986996fa6d (diff) | |
download | rneovim-d9d890562e43493c999f8a6ff2b848959686f5b6.tar.gz rneovim-d9d890562e43493c999f8a6ff2b848959686f5b6.tar.bz2 rneovim-d9d890562e43493c999f8a6ff2b848959686f5b6.zip |
refactor(lua): rename tbl_islist => islist
ref #24572
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/deprecated.txt | 1 | ||||
-rw-r--r-- | runtime/doc/lua.txt | 36 | ||||
-rw-r--r-- | runtime/doc/news.txt | 5 | ||||
-rw-r--r-- | runtime/lua/_vim9script.lua | 10 | ||||
-rw-r--r-- | runtime/lua/vim/_options.lua | 2 | ||||
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 14 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 2 | ||||
-rw-r--r-- | runtime/lua/vim/shared.lua | 12 |
8 files changed, 46 insertions, 36 deletions
diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index 1b57f34896..976bc05a64 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -172,6 +172,7 @@ LUA - vim.register_keystroke_callback() Use |vim.on_key()| instead. - *vim.pretty_print()* Use |vim.print()| instead. - *vim.loop* Use |vim.uv| instead. +- *vim.tbl_islist()* Use |vim.islist()| instead. - *vim.tbl_add_reverse_lookup()* NORMAL COMMANDS diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index dc1a4bb35d..3561c77dd5 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -2029,6 +2029,23 @@ vim.is_callable({f}) *vim.is_callable()* Return: ~ (`boolean`) `true` if `f` is callable, else `false` +vim.islist({t}) *vim.islist()* + Tests if `t` is a "list": a table indexed only by contiguous integers + starting from 1 (what |lua-length| calls a "regular array"). + + Empty table `{}` is a list, unless it was created by |vim.empty_dict()| or + returned as a dict-like |API| or Vimscript result, for example from + |rpcrequest()| or |vim.fn|. + + Parameters: ~ + • {t} (`table?`) + + Return: ~ + (`boolean`) `true` if list-like table, else `false`. + + See also: ~ + • |vim.tbl_isarray()| + vim.list_contains({t}, {value}) *vim.list_contains()* Checks if a list-like table (integer keys without gaps) contains `value`. @@ -2284,7 +2301,7 @@ vim.tbl_isarray({t}) *vim.tbl_isarray()* non-contiguous). If the indexes start from 1 and are contiguous then the array is also a - list. |vim.tbl_islist()| + list. |vim.islist()| Empty table `{}` is an array, unless it was created by |vim.empty_dict()| or returned as a dict-like |API| or Vimscript result, for example from @@ -2311,23 +2328,6 @@ vim.tbl_isempty({t}) *vim.tbl_isempty()* See also: ~ • https://github.com/premake/premake-core/blob/master/src/base/table.lua -vim.tbl_islist({t}) *vim.tbl_islist()* - Tests if `t` is a "list": a table indexed only by contiguous integers - starting from 1 (what |lua-length| calls a "regular array"). - - Empty table `{}` is a list, unless it was created by |vim.empty_dict()| or - returned as a dict-like |API| or Vimscript result, for example from - |rpcrequest()| or |vim.fn|. - - Parameters: ~ - • {t} (`table`) - - Return: ~ - (`boolean`) `true` if list-like table, else `false`. - - See also: ~ - • |vim.tbl_isarray()| - vim.tbl_keys({t}) *vim.tbl_keys()* Return a list of all keys used in a table. However, the order of the return table of keys is not guaranteed. diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 7da6fb4ff8..ed7da4f9de 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -22,7 +22,7 @@ The following changes may require adaptations in user config or plugins. set guicursor+=n-v-c:blinkon500-blinkoff500 < -• |vim.tbl_islist()| now checks whether a table is actually list-like (i.e., +• |vim.islist()| now checks whether a table is actually list-like (i.e., has integer keys without gaps and starting from 1). For the previous behavior (only check for integer keys, allow gaps or not starting with 1), use |vim.tbl_isarray()|. @@ -155,6 +155,8 @@ unreleased features on Nvim HEAD. • Removed vim.iter.map(), vim.iter.filter(), vim.iter.totable(). +• Renamed vim.tbl_islist() to vim.islist(). + ============================================================================== NEW FEATURES *news-features* @@ -563,5 +565,6 @@ release. • vim.shared functions: - |vim.tbl_add_reverse_lookup()| + - |vim.tbl_islist()| vim:tw=78:ts=8:sw=2:et:ft=help:norl: diff --git a/runtime/lua/_vim9script.lua b/runtime/lua/_vim9script.lua index ca0e913d51..23c078cb87 100644 --- a/runtime/lua/_vim9script.lua +++ b/runtime/lua/_vim9script.lua @@ -82,7 +82,7 @@ local vim9 = (function() end M.index = function(obj, idx) - if vim.tbl_islist(obj) then + if vim.islist(obj) then if idx < 0 then return obj[#obj + idx + 1] else @@ -127,7 +127,7 @@ local vim9 = (function() assert(type(finish) == 'number') local slicer - if vim.tbl_islist(obj) then + if vim.islist(obj) then slicer = vim.list_slice elseif type(obj) == 'string' then slicer = string.sub @@ -168,7 +168,7 @@ local vim9 = (function() end M.iter = function(expr) - if vim.tbl_islist(expr) then + if vim.islist(expr) then return ipairs(expr) else return pairs(expr) @@ -234,7 +234,7 @@ vim9['convert'] = (function() elseif type(val) == 'table' then if vim.tbl_isempty(val) then return vim.empty_dict() - elseif vim.tbl_islist(val) then + elseif vim.islist(val) then error(string.format('Cannot pass list to dictionary? %s', vim.inspect(val))) else return val @@ -280,7 +280,7 @@ vim9['fn'] = (function() error("haven't written this code yet") end - if vim.tbl_islist(right) then + if vim.islist(right) then vim.list_extend(left, right) return left else diff --git a/runtime/lua/vim/_options.lua b/runtime/lua/vim/_options.lua index 13ad6cc58f..b41e298dd7 100644 --- a/runtime/lua/vim/_options.lua +++ b/runtime/lua/vim/_options.lua @@ -642,7 +642,7 @@ end --- @param t table<any,any> --- @param val any local function remove_one_item(t, val) - if vim.tbl_islist(t) then + if vim.islist(t) then local remove_index = nil for i, v in ipairs(t) do if v == val then diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 6233bb7058..5e4835ab88 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -974,7 +974,7 @@ function M.set(namespace, bufnr, diagnostics, opts) bufnr = { bufnr, 'n' }, diagnostics = { diagnostics, - vim.tbl_islist, + vim.islist, 'a list of diagnostics', }, opts = { opts, 't', true }, @@ -1186,7 +1186,7 @@ M.handlers.signs = { bufnr = { bufnr, 'n' }, diagnostics = { diagnostics, - vim.tbl_islist, + vim.islist, 'a list of diagnostics', }, opts = { opts, 't', true }, @@ -1309,7 +1309,7 @@ M.handlers.underline = { bufnr = { bufnr, 'n' }, diagnostics = { diagnostics, - vim.tbl_islist, + vim.islist, 'a list of diagnostics', }, opts = { opts, 't', true }, @@ -1382,7 +1382,7 @@ M.handlers.virtual_text = { bufnr = { bufnr, 'n' }, diagnostics = { diagnostics, - vim.tbl_islist, + vim.islist, 'a list of diagnostics', }, opts = { opts, 't', true }, @@ -1576,7 +1576,7 @@ function M.show(namespace, bufnr, diagnostics, opts) diagnostics = { diagnostics, function(v) - return v == nil or vim.tbl_islist(v) + return v == nil or vim.islist(v) end, 'a list of diagnostics', }, @@ -2120,7 +2120,7 @@ function M.toqflist(diagnostics) vim.validate({ diagnostics = { diagnostics, - vim.tbl_islist, + vim.islist, 'a list of diagnostics', }, }) @@ -2160,7 +2160,7 @@ function M.fromqflist(list) vim.validate({ list = { list, - vim.tbl_islist, + vim.islist, 'a list of quickfix items', }, }) diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index a15096fdad..d6579cf4b3 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -428,7 +428,7 @@ local function location_handler(_, result, ctx, config) -- textDocument/definition can return Location or Location[] -- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition - if not vim.tbl_islist(result) then + if not vim.islist(result) then result = { result } end diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index eb51c244ef..6d9e4ad809 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -601,7 +601,7 @@ end --- Tests if `t` is an "array": a table indexed _only_ by integers (potentially non-contiguous). --- ---- If the indexes start from 1 and are contiguous then the array is also a list. |vim.tbl_islist()| +--- If the indexes start from 1 and are contiguous then the array is also a list. |vim.islist()| --- --- Empty table `{}` is an array, unless it was created by |vim.empty_dict()| or returned as --- a dict-like |API| or Vimscript result, for example from |rpcrequest()| or |vim.fn|. @@ -640,6 +640,12 @@ function vim.tbl_isarray(t) end end +--- @deprecated +function vim.tbl_islist(t) + vim.deprecate('vim.tbl_islist', 'vim.islist', '0.12') + return vim.islist(t) +end + --- Tests if `t` is a "list": a table indexed _only_ by contiguous integers starting from 1 (what --- |lua-length| calls a "regular array"). --- @@ -648,9 +654,9 @@ end --- ---@see |vim.tbl_isarray()| --- ----@param t table +---@param t? table ---@return boolean `true` if list-like table, else `false`. -function vim.tbl_islist(t) +function vim.islist(t) if type(t) ~= 'table' then return false end |