From c43c745a14dced87a23227d7be4f1c33d4455193 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 9 Aug 2023 11:06:13 +0200 Subject: fix(lua): improve annotations for stricter luals diagnostics (#24609) Problem: luals returns stricter diagnostics with bundled luarc.json Solution: Improve some function and type annotations: * use recognized uv.* types * disable diagnostic for global `vim` in shared.lua * docs: don't start comment lines with taglink (otherwise LuaLS will interpret it as a type) * add type alias for lpeg pattern * fix return annotation for `vim.secure.trust` * rename local Range object in vim.version (shadows `Range` in vim.treesitter) * fix some "missing fields" warnings * add missing required fields for test functions in eval.lua * rename lsp meta files for consistency --- runtime/lua/vim/version.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'runtime/lua/vim/version.lua') diff --git a/runtime/lua/vim/version.lua b/runtime/lua/vim/version.lua index 96889438eb..056e1678ff 100644 --- a/runtime/lua/vim/version.lua +++ b/runtime/lua/vim/version.lua @@ -212,15 +212,15 @@ function M.last(versions) return last end ----@class Range +---@class VersionRange ---@field from Version ---@field to? Version -local Range = {} +local VersionRange = {} --- @private --- ---@param version string|Version -function Range:has(version) +function VersionRange:has(version) if type(version) == 'string' then ---@diagnostic disable-next-line: cast-local-type version = M.parse(version) @@ -266,7 +266,7 @@ end --- @param spec string Version range "spec" function M.range(spec) -- Adapted from https://github.com/folke/lazy.nvim if spec == '*' or spec == '' then - return setmetatable({ from = M.parse('0.0.0') }, { __index = Range }) + return setmetatable({ from = M.parse('0.0.0') }, { __index = VersionRange }) end ---@type number? @@ -280,7 +280,7 @@ function M.range(spec) -- Adapted from https://github.com/folke/lazy.nvim return setmetatable({ from = ra and ra.from, to = rb and (#parts == 3 and rb.from or rb.to), - }, { __index = Range }) + }, { __index = VersionRange }) end ---@type string, string local mods, version = spec:lower():match('^([%^=<>~]*)(.*)$') @@ -326,7 +326,7 @@ function M.range(spec) -- Adapted from https://github.com/folke/lazy.nvim end end end - return setmetatable({ from = from, to = to }, { __index = Range }) + return setmetatable({ from = from, to = to }, { __index = VersionRange }) end end -- cgit