diff options
author | Folke Lemaitre <folke.lemaitre@gmail.com> | 2022-09-28 13:22:08 +0200 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2022-10-06 15:42:21 +0100 |
commit | 1da7b4eb699fb04cc97dec389470fd0fbd64091d (patch) | |
tree | 6c060f502d43e88cc7d69fe37e31b8a65316c5b2 /runtime/lua/vim/shared.lua | |
parent | 24a1c7f556bba35a9c31c2fdd19cf4b8c00a4395 (diff) | |
download | rneovim-1da7b4eb699fb04cc97dec389470fd0fbd64091d.tar.gz rneovim-1da7b4eb699fb04cc97dec389470fd0fbd64091d.tar.bz2 rneovim-1da7b4eb699fb04cc97dec389470fd0fbd64091d.zip |
feat: added support for specifying types for lua2dox
Diffstat (limited to 'runtime/lua/vim/shared.lua')
-rw-r--r-- | runtime/lua/vim/shared.lua | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 5566bd5e35..fa2af57cfc 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -63,7 +63,7 @@ end)() ---@param s string String to split ---@param sep string Separator or pattern ---@param plain boolean If `true` use `sep` literally (passed to string.find) ----@return fun():string Iterator over the split components +---@return fun():string (function) Iterator over the split components function vim.gsplit(s, sep, plain) vim.validate({ s = { s, 's' }, sep = { sep, 's' }, plain = { plain, 'b', true } }) @@ -112,7 +112,7 @@ end --- ---@param s string String to split ---@param sep string Separator or pattern ----@param kwargs {plain: boolean, trimempty: boolean}|nil Keyword arguments: +---@param kwargs? {plain: boolean, trimempty: boolean} (table|nil) Keyword arguments: --- - plain: (boolean) If `true` use `sep` literally (passed to string.find) --- - trimempty: (boolean) If `true` remove empty items from the front --- and back of the list @@ -159,9 +159,9 @@ end --- ---@see From https://github.com/premake/premake-core/blob/master/src/base/table.lua --- ----@param t table<T, any> Table +---@param t table<T, any> (table) Table ---@generic T: table ----@return T[] List of keys +---@return T[] (list) List of keys function vim.tbl_keys(t) assert(type(t) == 'table', string.format('Expected table, got %s', type(t))) @@ -176,8 +176,8 @@ end --- However, the order of the return table of values is not guaranteed. --- ---@generic T ----@param t table<any, T> Table ----@return T[] List of values +---@param t table<any, T> (table) Table +---@return T[] (list) List of values function vim.tbl_values(t) assert(type(t) == 'table', string.format('Expected table, got %s', type(t))) @@ -191,8 +191,8 @@ end --- Apply a function to all values of a table. --- ---@generic T ----@param func fun(value: T): any Function ----@param t table<any, T> Table +---@param func fun(value: T): any (function) Function +---@param t table<any, T> (table) Table ---@return table Table of transformed values function vim.tbl_map(func, t) vim.validate({ func = { func, 'c' }, t = { t, 't' } }) @@ -207,9 +207,9 @@ end --- Filter a table using a predicate function --- ---@generic T ----@param func fun(value: T): boolean Function ----@param t table<any, T> Table ----@return T[] Table of filtered values +---@param func fun(value: T): boolean (function) Function +---@param t table<any, T> (table) Table +---@return T[] (table) Table of filtered values function vim.tbl_filter(func, t) vim.validate({ func = { func, 'c' }, t = { t, 't' } }) @@ -313,12 +313,12 @@ end --- ---@generic T1: table ---@generic T2: table ----@param behavior "error"|"keep"|"force" Decides what to do if a key is found in more than one map: +---@param behavior "error"|"keep"|"force" (string) Decides what to do if a key is found in more than one map: --- - "error": raise an error --- - "keep": use value from the leftmost map --- - "force": use value from the rightmost map ---@param ... T2 Two or more map-like tables ----@return T1|T2 Merged table +---@return T1|T2 (table) Merged table function vim.tbl_deep_extend(behavior, ...) return tbl_extend(behavior, true, ...) end @@ -515,10 +515,10 @@ end --- Creates a copy of a table containing only elements from start to end (inclusive) --- ---@generic T ----@param list T[] Table +---@param list T[] (list) Table ---@param start number Start range of slice ---@param finish number End range of slice ----@return T[] Copy of table sliced from start to finish (inclusive) +---@return T[] (list) Copy of table sliced from start to finish (inclusive) function vim.list_slice(list, start, finish) local new_list = {} for i = start or 1, finish or #list do |