diff options
Diffstat (limited to 'runtime/lua/vim/_editor.lua')
-rw-r--r-- | runtime/lua/vim/_editor.lua | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 4e39abb2be..f527fc194c 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -74,7 +74,6 @@ vim.log = { --- Examples: --- --- ```lua ---- --- local on_exit = function(obj) --- print(obj.code) --- print(obj.signal) @@ -190,6 +189,7 @@ function vim._os_proc_children(ppid) return children end +--- @nodoc --- @class vim.inspect.Opts --- @field depth? integer --- @field newline? string @@ -274,6 +274,7 @@ do for _, line in ipairs(lines) do nchars = nchars + line:len() end + --- @type integer, integer local row, col = unpack(vim.api.nvim_win_get_cursor(0)) local bufline = vim.api.nvim_buf_get_lines(0, row - 1, row, true)[1] local firstline = lines[1] @@ -354,8 +355,11 @@ end -- vim.fn.{func}(...) ---@nodoc vim.fn = setmetatable({}, { + --- @param t table<string,function> + --- @param key string + --- @return function __index = function(t, key) - local _fn + local _fn --- @type function if vim.api[key] ~= nil then _fn = function() error(string.format('Tried to call API function with vim.fn: use vim.api.%s instead', key)) @@ -454,7 +458,7 @@ vim.cmd = setmetatable({}, { end, }) ---- @class vim.var_accessor +--- @class (private) vim.var_accessor --- @field [string] any --- @field [integer] vim.var_accessor @@ -497,7 +501,7 @@ end ---@param bufnr integer Buffer number, or 0 for current buffer ---@param pos1 integer[]|string Start of region as a (line, column) tuple or |getpos()|-compatible string ---@param pos2 integer[]|string End of region as a (line, column) tuple or |getpos()|-compatible string ----@param regtype string \|setreg()|-style selection type +---@param regtype string [setreg()]-style selection type ---@param inclusive boolean Controls whether the ending column is inclusive (see also 'selection'). ---@return table region Dict of the form `{linenr = {startcol,endcol}}`. `endcol` is exclusive, and ---whole lines are returned as `{startcol,endcol} = {0,-1}`. @@ -619,7 +623,7 @@ function vim.notify(msg, level, opts) -- luacheck: no unused args end do - local notified = {} + local notified = {} --- @type table<string,true> --- Displays a notification only one time. --- @@ -640,7 +644,7 @@ do end end -local on_key_cbs = {} +local on_key_cbs = {} --- @type table<integer,function> --- Adds Lua function {fn} with namespace id {ns_id} as a listener to every, --- yes every, input key. @@ -710,6 +714,7 @@ end --- 2. Can we get it to return things from global namespace even with `print(` in front. --- --- @param pat string +--- @return any[], integer function vim._expand_pat(pat, env) env = env or _G @@ -742,7 +747,7 @@ function vim._expand_pat(pat, env) if type(final_env) ~= 'table' then return {}, 0 end - local key + local key --- @type any -- Normally, we just have a string -- Just attempt to get the string directly from the environment @@ -784,7 +789,8 @@ function vim._expand_pat(pat, env) end end - local keys = {} + local keys = {} --- @type table<string,true> + --- @param obj table<any,any> local function insert_keys(obj) for k, _ in pairs(obj) do if type(k) == 'string' and string.sub(k, 1, string.len(match_part)) == match_part then @@ -812,6 +818,7 @@ function vim._expand_pat(pat, env) end --- @param lua_string string +--- @return (string|string[])[], integer vim._expand_pat_get_parts = function(lua_string) local parts = {} @@ -869,6 +876,7 @@ vim._expand_pat_get_parts = function(lua_string) end end + --- @param val any[] parts = vim.tbl_filter(function(val) return #val > 0 end, parts) @@ -879,7 +887,7 @@ end do -- Ideally we should just call complete() inside omnifunc, though there are -- some bugs, so fake the two-step dance for now. - local matches + local matches --- @type any[] --- Omnifunc for completing Lua values from the runtime Lua interpreter, --- similar to the builtin completion for the `:lua` command. @@ -899,12 +907,6 @@ do end end ----@private -function vim.pretty_print(...) - vim.deprecate('vim.pretty_print()', 'vim.print()', '0.10') - return vim.print(...) -end - --- "Pretty prints" the given arguments and returns them unmodified. --- --- Example: @@ -1048,7 +1050,7 @@ function vim.deprecate(name, alternative, version, plugin, backtrace) -- e.g., when planned to be removed in version = '0.12' (soft-deprecated since 0.10-dev), -- show warnings since 0.11, including 0.11-dev (hard_deprecated_since = 0.11-dev). if plugin == 'Nvim' then - local current_version = vim.version() ---@type Version + local current_version = vim.version() ---@type vim.Version local removal_version = assert(vim.version.parse(version)) local is_hard_deprecated ---@type boolean |