From 97bea3163a3fe50359e7f6ffda747e28974a818a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 13 Dec 2023 12:00:11 +0000 Subject: feat(lsp): more annotations --- runtime/lua/vim/_editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 6cccbe8313..0bb1becf58 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -478,7 +478,7 @@ do end vim.g = make_dict_accessor('g', false) - vim.v = make_dict_accessor('v', false) + vim.v = make_dict_accessor('v', false) --[[@as vim.v]] vim.b = make_dict_accessor('b') vim.w = make_dict_accessor('w') vim.t = make_dict_accessor('t') -- cgit From 0a598c13b1863ba1aff378027c4376e3ab7048ee Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 25 Dec 2023 16:31:38 +0100 Subject: feat(vim.deprecate): only issue warning if neovim version is high enough As specified by MAINTAIN.md, features should be soft deprecated at first (meaning no warnings) to give people a chance to adjust. The problem with this approach is that deprecating a feature becomes harder than usual as during the soft deprecation period you need to remember not to issue a warning, and during the hard deprecation period you need to remember to start issuing a warning. This behavior is only enforced if the `plugin` parameter is `nil` as plugins may not want this specific behavior. --- runtime/lua/vim/_editor.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 0bb1becf58..dda89e2bdb 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -1019,6 +1019,18 @@ end --- ---@return string|nil # Deprecated message, or nil if no message was shown. function vim.deprecate(name, alternative, version, plugin, backtrace) + -- Only issue warning if feature is hard-deprecated as specified by MAINTAIN.md. + if plugin == nil then + local current_version = vim.version() + local deprecated_version = assert(vim.version.parse(version)) + local soft_deprecated_version = + { deprecated_version.major, deprecated_version.minor - 1, deprecated_version.patch } + local deprecate = vim.version.lt(current_version, soft_deprecated_version) + if deprecate then + return + end + end + local msg = ('%s is deprecated'):format(name) plugin = plugin or 'Nvim' msg = alternative and ('%s, use %s instead.'):format(msg, alternative) or msg -- cgit From 5f9d4d8afeb5dc3d5df4965c24cbb4c6e01694f7 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 25 Dec 2023 21:28:28 +0100 Subject: refactor: use vim.deprecate on all deprecated functions --- runtime/lua/vim/_editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index dda89e2bdb..0b338fa86f 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -888,7 +888,7 @@ end ---@private function vim.pretty_print(...) - vim.deprecate('vim.pretty_print', 'vim.print', '0.10') + vim.deprecate('vim.pretty_print()', 'vim.print()', '0.10') return vim.print(...) end -- cgit From d51b6157473c4830313b566116aa3ad38dc97412 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Wed, 13 Dec 2023 14:04:24 +0100 Subject: refactor: fix luals warnings --- runtime/lua/vim/_editor.lua | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 0b338fa86f..cde61697b6 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -156,10 +156,10 @@ function vim._os_proc_info(pid) elseif r.code ~= 0 then error('command failed: ' .. vim.fn.string(cmd)) end - local ppid = assert(vim.system({ 'ps', '-p', pid, '-o', 'ppid=' }):wait().stdout) + local ppid_string = assert(vim.system({ 'ps', '-p', pid, '-o', 'ppid=' }):wait().stdout) -- Remove trailing whitespace. name = vim.trim(name):gsub('^.*/', '') - ppid = tonumber(ppid) or -1 + local ppid = tonumber(ppid_string) or -1 return { name = name, pid = pid, @@ -533,20 +533,21 @@ function vim.region(bufnr, pos1, pos2, regtype, inclusive) local region = {} for l = pos1[1], pos2[1] do - local c1, c2 + local c1 --- @type number + local c2 --- @type number if regtype:byte() == 22 then -- block selection: take width from regtype c1 = pos1[2] - c2 = c1 + regtype:sub(2) + c2 = c1 + tonumber(regtype:sub(2)) -- and adjust for non-ASCII characters local bufline = vim.api.nvim_buf_get_lines(bufnr, l, l + 1, true)[1] local utflen = vim.str_utfindex(bufline, #bufline) if c1 <= utflen then - c1 = vim.str_byteindex(bufline, c1) + c1 = assert(tonumber(vim.str_byteindex(bufline, c1))) else c1 = #bufline + 1 end if c2 <= utflen then - c2 = vim.str_byteindex(bufline, c2) + c2 = assert(tonumber(vim.str_byteindex(bufline, c2))) else c2 = #bufline + 1 end @@ -576,7 +577,7 @@ end ---@return table timer luv timer object function vim.defer_fn(fn, timeout) vim.validate({ fn = { fn, 'c', true } }) - local timer = vim.uv.new_timer() + local timer = assert(vim.uv.new_timer()) timer:start( timeout, 0, @@ -601,6 +602,7 @@ end ---@param msg string Content of the notification to show to the user. ---@param level integer|nil One of the values from |vim.log.levels|. ---@param opts table|nil Optional parameters. Unused by default. +---@diagnostic disable-next-line: unused-local function vim.notify(msg, level, opts) -- luacheck: no unused args if level == vim.log.levels.ERROR then vim.api.nvim_err_writeln(msg) @@ -700,6 +702,8 @@ end --- --- 1. Can we get it to just return things in the global namespace with that name prefix --- 2. Can we get it to return things from global namespace even with `print(` in front. +--- +--- @param pat string function vim._expand_pat(pat, env) env = env or _G @@ -801,11 +805,13 @@ function vim._expand_pat(pat, env) return keys, #prefix_match_pat end +--- @param lua_string string vim._expand_pat_get_parts = function(lua_string) local parts = {} local accumulator, search_index = '', 1 - local in_brackets, bracket_end = false, -1 + local in_brackets = false + local bracket_end = -1 --- @type integer? local string_char = nil for idx = 1, #lua_string do local s = lua_string:sub(idx, idx) @@ -938,9 +944,12 @@ function vim.keycode(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end +--- @param server_addr string +--- @param connect_error string function vim._cs_remote(rcid, server_addr, connect_error, args) + --- @return string local function connection_failure_errmsg(consequence) - local explanation + local explanation --- @type string if server_addr == '' then explanation = 'No server specified with --server' else @@ -983,7 +992,7 @@ function vim._cs_remote(rcid, server_addr, connect_error, args) local res = tostring(vim.rpcrequest(rcid, 'nvim_eval', args[2])) return { result = res, should_exit = true, tabbed = false } elseif subcmd ~= '' then - return { errmsg = 'Unknown option argument: ' .. args[1] } + return { errmsg = 'Unknown option argument: ' .. tostring(args[1]) } end if rcid == 0 then -- cgit From 2f9ee9b6cfc61a0504fc0bc22bdf481828e2ea91 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 9 Jan 2024 17:36:46 +0000 Subject: fix(doc): improve doc generation of types using lpeg Added a lpeg grammar for LuaCATS and use it in lua2dox.lua --- runtime/lua/vim/_editor.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index cde61697b6..4fe601dfd5 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -95,7 +95,7 @@ vim.log = { --- throws an error if {cmd} cannot be run. --- --- @param cmd (string[]) Command to execute ---- @param opts (SystemOpts|nil) Options: +--- @param opts vim.SystemOpts? Options: --- - cwd: (string) Set the current working directory for the sub-process. --- - env: table Set environment variables for the new process. Inherits the --- current environment with `NVIM` set to |v:servername|. @@ -118,7 +118,7 @@ vim.log = { --- parent exits. Note that the child process will still keep the parent's event loop alive --- unless the parent process calls |uv.unref()| on the child's process handle. --- ---- @param on_exit (function|nil) Called when subprocess exits. When provided, the command runs +--- @param on_exit? fun(out: vim.SystemCompleted) Called when subprocess exits. When provided, the command runs --- asynchronously. Receives SystemCompleted object, see return of SystemObj:wait(). --- --- @return vim.SystemObj Object with the fields: @@ -219,10 +219,9 @@ do --- ``` --- ---@see |paste| - ---@alias paste_phase -1 | 1 | 2 | 3 --- ---@param lines string[] # |readfile()|-style list of lines to paste. |channel-lines| - ---@param phase paste_phase -1: "non-streaming" paste: the call contains all lines. + ---@param phase (-1|1|2|3) -1: "non-streaming" paste: the call contains all lines. --- If paste is "streamed", `phase` indicates the stream state: --- - 1: starts the paste (exactly once) --- - 2: continues the paste (zero or more times) -- cgit From 14b7ffcf89bc448b626df3d9e19f9f5a3682ae2b Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 16 Jan 2024 10:30:08 +0000 Subject: feat: add __call typing for vim.inspect() --- runtime/lua/vim/_editor.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 4fe601dfd5..52a21587f4 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -190,12 +190,18 @@ function vim._os_proc_children(ppid) return children end +--- @class vim.inspect.Opts +--- @field depth? integer +--- @field newline? string +--- @field process? fun(item:any, path: string[]): any + --- Gets a human-readable representation of the given object. --- ---@see |vim.print()| ---@see https://github.com/kikito/inspect.lua ---@see https://github.com/mpeterv/vinspect ---@return string +---@overload fun(x: any, opts?: vim.inspect.Opts): string vim.inspect = vim.inspect do -- cgit From 5a8fe0769cc9c5d8323b073d5c45ee37ce91c049 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Mon, 15 Jan 2024 14:19:34 -0500 Subject: fix(vim.deprecate): show deprecation warning in devel versions as well Problem: On devel(nightly) versions, deprecation warnings for hard-deprecated features are not being displayed. E.g., - to be removed in: 0.11 - hard-deprecation since 0.10 - soft-deprecation since 0.9 then 0.10-nightly (0.10.0-dev) versions as well as 0.10.0 (stable) should display the deprecation warning message. Solution: Improve the code and logic on `vim.deprecate()`, and improve test cases with mocked `vim.version()`. --- runtime/lua/vim/_editor.lua | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 52a21587f4..fd49f63558 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -1033,21 +1033,44 @@ end --- ---@return string|nil # Deprecated message, or nil if no message was shown. function vim.deprecate(name, alternative, version, plugin, backtrace) + vim.validate { + name = { name, 'string' }, + alternative = { alternative, 'string', true }, + version = { version, 'string', true }, + plugin = { plugin, 'string', true }, + } + plugin = plugin or 'Nvim' + -- Only issue warning if feature is hard-deprecated as specified by MAINTAIN.md. - if plugin == nil then - local current_version = vim.version() - local deprecated_version = assert(vim.version.parse(version)) - local soft_deprecated_version = - { deprecated_version.major, deprecated_version.minor - 1, deprecated_version.patch } - local deprecate = vim.version.lt(current_version, soft_deprecated_version) - if deprecate then + -- 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 removal_version = assert(vim.version.parse(version)) + local is_hard_deprecated ---@type boolean + + if removal_version.minor > 0 then + local hard_deprecated_since = assert(vim.version._version({ + major = removal_version.major, + minor = removal_version.minor - 1, + patch = 0, + prerelease = 'dev', -- Show deprecation warnings in devel (nightly) version as well + })) + is_hard_deprecated = (current_version >= hard_deprecated_since) + else + -- Assume there will be no next minor version before bumping up the major version; + -- therefore we can always show a warning. + assert(removal_version.minor == 0, vim.inspect(removal_version)) + is_hard_deprecated = true + end + + if not is_hard_deprecated then return end end local msg = ('%s is deprecated'):format(name) - plugin = plugin or 'Nvim' - msg = alternative and ('%s, use %s instead.'):format(msg, alternative) or msg + msg = alternative and ('%s, use %s instead.'):format(msg, alternative) or (msg .. '.') msg = ('%s%s\nThis feature will be removed in %s version %s'):format( msg, (plugin == 'Nvim' and ' :help deprecated' or ''), -- cgit From 0054c185001e54316c0ee36841dfe111878a321d Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 23 Jan 2024 00:53:15 +0000 Subject: test: typing for screen.lua Very rough buts resolves most diagnostic errors and should provide some useful hovers. --- runtime/lua/vim/_editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index fd49f63558..c130eb1958 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -352,7 +352,7 @@ function vim.schedule_wrap(fn) end -- vim.fn.{func}(...) ----@private +---@nodoc vim.fn = setmetatable({}, { __index = function(t, key) local _fn -- cgit From 6c168c0f4d777d7586b47a05d2539210ce711f1c Mon Sep 17 00:00:00 2001 From: altermo <107814000+altermo@users.noreply.github.com> Date: Mon, 12 Feb 2024 13:03:53 +0100 Subject: docs: correct on_key docs (#27429) --- runtime/lua/vim/_editor.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index c130eb1958..c5a6e65e86 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -652,8 +652,9 @@ local on_key_cbs = {} ---@note {fn} will not be cleared by |nvim_buf_clear_namespace()| ---@note {fn} will receive the keys after mappings have been evaluated --- ----@param fn fun(key: string) Function invoked on every key press. |i_CTRL-V| ---- Returning nil removes the callback associated with namespace {ns_id}. +---@param fn fun(key: string)? Function invoked on every key press. |i_CTRL-V| +--- Passing in nil when {ns_id} is specified removes the +--- callback associated with namespace {ns_id}. ---@param ns_id integer? Namespace ID. If nil or 0, generates and returns a --- new |nvim_create_namespace()| id. --- -- cgit From 9beb40a4db5613601fc1a4b828a44e5977eca046 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 15 Feb 2024 17:16:04 +0000 Subject: feat(docs): replace lua2dox.lua Problem: The documentation flow (`gen_vimdoc.py`) has several issues: - it's not very versatile - depends on doxygen - doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C. - The intermediate XML files and filters makes it too much like a rube goldberg machine. Solution: Re-implement the flow using Lua, LPEG and treesitter. - `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic. - `lua2dox.lua` is gone! - No more XML files. - Doxygen is now longer used and instead we now use: - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`). - LPEG for C parsing (see `scripts/cdoc_parser.lua`) - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`). - Treesitter for Markdown parsing (see `scripts/text_utils.lua`). - The generated `runtime/doc/*.mpack` files have been removed. - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly. - Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change). --- runtime/lua/vim/_editor.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index c5a6e65e86..4e39abb2be 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -127,10 +127,10 @@ vim.log = { --- timeout the process is sent the KILL signal (9) and the exit code is set to 124. Cannot --- be called in |api-fast|. --- - SystemCompleted is an object with the fields: ---- - code: (integer) ---- - signal: (integer) ---- - stdout: (string), nil if stdout argument is passed ---- - stderr: (string), nil if stderr argument is passed +--- - code: (integer) +--- - signal: (integer) +--- - stdout: (string), nil if stdout argument is passed +--- - stderr: (string), nil if stderr argument is passed --- - kill (fun(signal: integer|string)) --- - write (fun(data: string|nil)) Requires `stdin=true`. Pass `nil` to close the stream. --- - is_closing (fun(): boolean) @@ -706,8 +706,8 @@ end --- Generates a list of possible completions for the string. --- String has the pattern. --- ---- 1. Can we get it to just return things in the global namespace with that name prefix ---- 2. Can we get it to return things from global namespace even with `print(` in front. +--- 1. Can we get it to just return things in the global namespace with that name prefix +--- 2. Can we get it to return things from global namespace even with `print(` in front. --- --- @param pat string function vim._expand_pat(pat, env) @@ -885,6 +885,7 @@ do --- similar to the builtin completion for the `:lua` command. --- --- Activate using `set omnifunc=v:lua.vim.lua_omnifunc` in a Lua buffer. + --- @param find_start 1|0 function vim.lua_omnifunc(find_start, _) if find_start == 1 then local line = vim.api.nvim_get_current_line() @@ -914,6 +915,7 @@ end --- --- @see |vim.inspect()| --- @see |:=| +--- @param ... any --- @return any # given arguments. function vim.print(...) if vim.in_fast_event() then -- cgit From a5fe8f59d98398d04bed8586cee73864bbcdde92 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 27 Feb 2024 15:20:32 +0000 Subject: docs: improve/add documentation of Lua types - Added `@inlinedoc` so single use Lua types can be inlined into the functions docs. E.g. ```lua --- @class myopts --- @inlinedoc --- --- Documentation for some field --- @field somefield integer --- @param opts myOpts function foo(opts) end ``` Will be rendered as ``` foo(opts) Parameters: - {opts} (table) Object with the fields: - somefield (integer) Documentation for some field ``` - Marked many classes with with `@nodoc` or `(private)`. We can eventually introduce these when we want to. --- runtime/lua/vim/_editor.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 4e39abb2be..d14007312e 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -190,6 +190,7 @@ function vim._os_proc_children(ppid) return children end +--- @nodoc --- @class vim.inspect.Opts --- @field depth? integer --- @field newline? string @@ -454,7 +455,7 @@ vim.cmd = setmetatable({}, { end, }) ---- @class vim.var_accessor +--- @class (private) vim.var_accessor --- @field [string] any --- @field [integer] vim.var_accessor @@ -1048,7 +1049,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 -- cgit From ea44f74d84f87ce5aff2ef7797be986900bd74a6 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 6 Mar 2024 10:03:55 +0000 Subject: refactor(types): more fixes --- runtime/lua/vim/_editor.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index d14007312e..c588802193 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -275,6 +275,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] @@ -355,8 +356,11 @@ end -- vim.fn.{func}(...) ---@nodoc vim.fn = setmetatable({}, { + --- @param t table + --- @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)) @@ -620,7 +624,7 @@ function vim.notify(msg, level, opts) -- luacheck: no unused args end do - local notified = {} + local notified = {} --- @type table --- Displays a notification only one time. --- @@ -641,7 +645,7 @@ do end end -local on_key_cbs = {} +local on_key_cbs = {} --- @type table --- Adds Lua function {fn} with namespace id {ns_id} as a listener to every, --- yes every, input key. @@ -711,6 +715,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 @@ -743,7 +748,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 @@ -785,7 +790,8 @@ function vim._expand_pat(pat, env) end end - local keys = {} + local keys = {} --- @type table + --- @param obj table 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 @@ -813,6 +819,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 = {} @@ -870,6 +877,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) @@ -880,7 +888,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. -- cgit From 649dd00fe2e54183cc210f24d36504a61e5ea605 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 8 Mar 2024 11:23:17 +0100 Subject: feat!: remove deprecated functions --- runtime/lua/vim/_editor.lua | 6 ------ 1 file changed, 6 deletions(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index c588802193..b73fad6bfa 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -908,12 +908,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: -- cgit From ade1b12f49c3b3914c74847d791eb90ea90b56b7 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 8 Mar 2024 12:25:18 +0000 Subject: docs: support inline markdown - Tags are now created with `[tag]()` - References are now created with `[tag]` - Code spans are no longer wrapped --- runtime/lua/vim/_editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index b73fad6bfa..6cf77b4648 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -502,7 +502,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}`. -- cgit