diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2023-03-06 10:04:13 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-06 10:04:13 -0500 |
| commit | 6969d3d7491fc2f10d80309b26dd0c26d211b1b3 (patch) | |
| tree | a6ef1d2c0195f9dd06109e0d977cb382c9b428df /runtime/doc | |
| parent | f9a46391ab5961fe6c6b7d1efdc96befdd495c11 (diff) | |
| parent | 74ffebf8ec725a25c2ae1dde81cf26b83fc7ae61 (diff) | |
| download | rneovim-6969d3d7491fc2f10d80309b26dd0c26d211b1b3.tar.gz rneovim-6969d3d7491fc2f10d80309b26dd0c26d211b1b3.tar.bz2 rneovim-6969d3d7491fc2f10d80309b26dd0c26d211b1b3.zip | |
Merge #22325 vim.version semver parser
Diffstat (limited to 'runtime/doc')
| -rw-r--r-- | runtime/doc/lua.txt | 67 | ||||
| -rw-r--r-- | runtime/doc/news.txt | 3 |
2 files changed, 70 insertions, 0 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 1eb5ab41e6..697cd86e8a 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -2497,4 +2497,71 @@ trust({opts}) *vim.secure.trust()* • true and full path of target file if operation was successful • false and error message on failure + +============================================================================== +Lua module: version *lua-version* + +cmp({v1}, {v2}, {opts}) *vim.version.cmp()* + Compares two strings ( `v1` and `v2` ) in semver format. + + Parameters: ~ + • {v1} (string) Version. + • {v2} (string) Version to compare with v1. + • {opts} (table|nil) Optional keyword arguments: + • strict (boolean): see `semver.parse` for details. Defaults + to false. + + Return: ~ + (integer) `-1` if `v1 < v2`, `0` if `v1 == v2`, `1` if `v1 > v2`. + +eq({v1}, {v2}) *vim.version.eq()* + Returns `true` if `v1` are `v2` are equal versions. + + Parameters: ~ + • {v1} (string) + • {v2} (string) + + Return: ~ + (boolean) + +gt({v1}, {v2}) *vim.version.gt()* + Returns `true` if `v1` is greater than `v2` . + + Parameters: ~ + • {v1} (string) + • {v2} (string) + + Return: ~ + (boolean) + +lt({v1}, {v2}) *vim.version.lt()* + Returns `true` if `v1` is less than `v2` . + + Parameters: ~ + • {v1} (string) + • {v2} (string) + + Return: ~ + (boolean) + +parse({version}, {opts}) *vim.version.parse()* + Parses a semantic version string. + + Ignores leading "v" and surrounding whitespace, e.g. " + v1.0.1-rc1+build.2", "1.0.1-rc1+build.2", "v1.0.1-rc1+build.2" and + "v1.0.1-rc1+build.2 " are all parsed as: > + + { major = 1, minor = 0, patch = 1, prerelease = "rc1", build = "build.2" } +< + + Parameters: ~ + • {version} (string) Version string to be parsed. + • {opts} (table|nil) Optional keyword arguments: + • strict (boolean): Default false. If `true` , no coercion is attempted on input not strictly + conforming to semver v2.0.0 ( https://semver.org/spec/v2.0.0.html ). E.g. `parse("v1.2")` returns nil. + + Return: ~ + (table|nil) parsed_version Parsed version table or `nil` if `version` + is invalid. + vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl: diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 415195e27e..28fdaa770d 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -55,6 +55,9 @@ NEW FEATURES *news-features* The following new APIs or features were added. +• Added |vim.version| for parsing and comparing version strings conforming to + the semver specification, see |lua-version|. + • A new environment variable named NVIM_APPNAME enables configuring the directories where Neovim should find its configuration and state files. See `:help $NVIM_APPNAME` . |