mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
doc(vim.version): options formatting #34716
This commit is contained in:
@@ -4044,15 +4044,14 @@ vim.version.parse({version}, {opts}) *vim.version.parse()*
|
|||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {version} (`string`) Version string to parse.
|
• {version} (`string`) Version string to parse.
|
||||||
• {opts} (`table?`) Optional keyword arguments:
|
• {opts} (`table?`) Options for parsing.
|
||||||
• strict (boolean): Default false. If `true`, no coercion
|
• {strict}? (`boolean`, default: `false`) If `true`, no
|
||||||
is attempted on input not conforming to semver v2.0.0. If
|
coercion is attempted on input not conforming to semver
|
||||||
`false`, `parse()` attempts to coerce input such as
|
v2.0.0. If `false`, `parse()` attempts to coerce input
|
||||||
"1.0", "0-x", "tmux 3.2a" into valid versions.
|
such as "1.0", "0-x", "tmux 3.2a" into valid versions.
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
(`vim.Version?`) parsed_version Version object or `nil` if input is
|
(`vim.Version?`) `Version` object or `nil` if input is invalid.
|
||||||
invalid.
|
|
||||||
|
|
||||||
See also: ~
|
See also: ~
|
||||||
• https://semver.org/spec/v2.0.0.html
|
• https://semver.org/spec/v2.0.0.html
|
||||||
|
@@ -435,6 +435,15 @@ function M.gt(v1, v2)
|
|||||||
return M.cmp(v1, v2) == 1
|
return M.cmp(v1, v2) == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@class vim.version.parse.Opts
|
||||||
|
---@inlinedoc
|
||||||
|
---
|
||||||
|
--- If `true`, no coercion is attempted on input not conforming to semver v2.0.0.
|
||||||
|
--- If `false`, `parse()` attempts to coerce input such as "1.0", "0-x", "tmux 3.2a" into valid
|
||||||
|
--- versions.
|
||||||
|
--- (default: `false`)
|
||||||
|
---@field strict? boolean
|
||||||
|
|
||||||
--- Parses a semantic version string and returns a version object which can be used with other
|
--- Parses a semantic version string and returns a version object which can be used with other
|
||||||
--- `vim.version` functions. For example "1.0.1-rc1+build.2" returns:
|
--- `vim.version` functions. For example "1.0.1-rc1+build.2" returns:
|
||||||
---
|
---
|
||||||
@@ -446,11 +455,8 @@ end
|
|||||||
---@since 11
|
---@since 11
|
||||||
---
|
---
|
||||||
---@param version string Version string to parse.
|
---@param version string Version string to parse.
|
||||||
---@param opts table|nil Optional keyword arguments:
|
---@param opts vim.version.parse.Opts? Options for parsing.
|
||||||
--- - strict (boolean): Default false. If `true`, no coercion is attempted on
|
---@return vim.Version? # `Version` object or `nil` if input is invalid.
|
||||||
--- input not conforming to semver v2.0.0. If `false`, `parse()` attempts to
|
|
||||||
--- coerce input such as "1.0", "0-x", "tmux 3.2a" into valid versions.
|
|
||||||
---@return vim.Version? parsed_version Version object or `nil` if input is invalid.
|
|
||||||
function M.parse(version, opts)
|
function M.parse(version, opts)
|
||||||
assert(type(version) == 'string', create_err_msg(version))
|
assert(type(version) == 'string', create_err_msg(version))
|
||||||
opts = opts or { strict = false }
|
opts = opts or { strict = false }
|
||||||
|
Reference in New Issue
Block a user