diff options
author | Christian Clason <c.clason@uni-graz.at> | 2023-08-09 11:06:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-09 11:06:13 +0200 |
commit | c43c745a14dced87a23227d7be4f1c33d4455193 (patch) | |
tree | 0cd5cf1cbbfa20be7fffbad696ba5ee97181847e /runtime/lua/vim/version.lua | |
parent | 8afdc1f3867a620c8235b3d3964b019b94657190 (diff) | |
download | rneovim-c43c745a14dced87a23227d7be4f1c33d4455193.tar.gz rneovim-c43c745a14dced87a23227d7be4f1c33d4455193.tar.bz2 rneovim-c43c745a14dced87a23227d7be4f1c33d4455193.zip |
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
Diffstat (limited to 'runtime/lua/vim/version.lua')
-rw-r--r-- | runtime/lua/vim/version.lua | 12 |
1 files changed, 6 insertions, 6 deletions
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 |