summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/version.lua
AgeCommit message (Collapse)AuthorFiles
2026-04-08feat(vim.version): add __eq to vim.VersionRange #38881ngicks1
Problem: vim.VersionRange had no __eq metamethod, so comparing 2 distinct but same value instances always returned false. In vim.pack.add this caused redundant lockfile rewrites, even when the resulting lockfile content was unchanged. Solution: Add __eq metamethod on vim.VersionRange
2026-03-13refactor: rename _ensure_integer => _assert_integerJustin M. Keyes1
2026-03-12refactor: integer functions, optimize asserts #34112Lewis Russell1
refactor(lua): add integer coercion helpers Add vim._tointeger() and vim._ensure_integer(), including optional base support, and switch integer-only tonumber()/assert call sites in the Lua runtime to use them. This also cleans up related integer parsing in LSP, health, loader, URI, tohtml, and Treesitter code. supported by AI
2025-07-23refactor(lua): use vim.system #34707Yochem van Rosmalen1
2025-07-01Merge #34715 vim.version improvementsJustin M. Keyes1
2025-06-30feat(vim.version): add `vim.version.intersect()`Evgeni Chasnovski1
Problem: No way to compute intersection of two version ranges, which is useful when computing version range that fits inside several reference ranges. Solution: Add `vim.version.intersect()`.
2025-06-30fix(vim.version): improve construction of '<=a.b.c' and '>a.b.c' rangesEvgeni Chasnovski1
Problem: `vim.version.range('<=a.b.c')` is not precise when it comes to its right hand side. This is due to version ranges using exclusive right hand side. While `vim.version.range('>a.b.c')` is not precise when it comes to its left hand side because left hand sides are inclusive. Solution: For '>=a.b.c' increase `to` from 'a.b.c' to the smallest reasonable version that is bigger than 'a.b.c'. For '<a.b.c' do the same for `from`. More proper solution is an explicit control over inclusivity of version range sides, but it has more side effects and requires design decisions.
2025-06-30doc(vim.version): options formatting #34716James Trew1
2025-06-30feat(vim.version): make `tostring()` return human-readable version rangeEvgeni Chasnovski1
Problem: `tostring()` applied to version range doesn't return human-readable text with information about the range. Solution: Add `__tostring()` method.
2025-06-30docs(vim.version): document `vim.VersionRange` as a dedicated classEvgeni Chasnovski1
2025-04-11fix(vim.version): vim.VersionRange:has(<prerelease>) (#33324)Phạm Bình An1
Problem: `vim.version.range('>=0.10'):has('0.12.0-dev')` returns false, which is wrong per semver. Solution: `vim.VersionRange:has()` shouldn't have special handling for prereleases (Why would we need it when `__eq`, `__lt`, `__le` already handle prereleases?). Closes #33316
2024-12-23docs(api): vim.version.range():has() method #31622Lukasz Piepiora1
Problem: The :has() method of the vim.version.range() result is not documented though it's mentioned in examples. Solution: Mention it in the range() result doc.
2024-10-04docs: render `@since` versions, 0 means experimental #30649Justin M. Keyes1
An implication of this current approach is that `NVIM_API_LEVEL` should be bumped when a new Lua function is added. TODO(future): add a lint check which requires `@since` on all new functions. ref #25416
2024-07-27fix(version): return nil with empty stringMaria José Solano1
2024-03-09docs: support inline markdownLewis Russell1
- Tags are now created with `[tag]()` - References are now created with `[tag]` - Code spans are no longer wrapped
2024-03-06refactor(types): more fixes (2)Lewis Russell1
2024-03-01docs: improve/add documentation of Lua typesLewis Russell1
- 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.
2024-02-27feat(docs): replace lua2dox.luaLewis Russell1
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).
2024-02-25refactor(types): fix miscellaneous type warningsMaria José Solano1
2024-01-21feat(vim.version): add `vim.version.le` and `vim.version.ge`Jongwook Choi1
- Problem: One cannot easily write something like, for example: `version_current >= {0, 10, 0}`; writing like `not vim.version.lt(version_current, {0, 10, 0})` is verbose. - Solution: add {`le`,`ge`} in addition to {`lt`,`gt`}. - Also improve typing on the operator methods: allow `string` as well. - Update the example in `vim.version.range()` docs: `ge` in place of `gt` better matches the semantics of `range:has`.
2024-01-03feat(lua): add noref to deepcopyLewis Russell1
Problem: Currently `deepcopy` hashes every single tables it copies so it can be reused. For tables of mostly unique items that are non recursive, this hashing is unnecessarily expensive Solution: Port the `noref` argument from Vimscripts `deepcopy()`. The below benchmark demonstrates the results for two extreme cases of tables of different sizes. One table that uses the same table lots of times and one with all unique tables. | test | `noref=false` (ms) | `noref=true` (ms) | | -------------------- | ------------------ | ----------------- | | unique tables (50) | 6.59 | 2.62 | | shared tables (50) | 3.24 | 6.40 | | unique tables (2000) | 23381.48 | 2884.53 | | shared tables (2000) | 3505.54 | 14038.80 | The results are basically the inverse of each other where `noref` is much more performance on tables with unique fields, and `not noref` is more performant on tables that reuse fields.
2023-09-14docs: replace <pre> with ``` (#25136)Gregory Anders1
2023-08-09fix(lua): improve annotations for stricter luals diagnostics (#24609)Christian Clason1
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
2023-07-18docs(lua): more improvements (#24387)Lewis Russell1
* docs(lua): teach lua2dox how to table * docs(lua): teach gen_vimdoc.py about local functions No more need to mark local functions with @private * docs(lua): mention @nodoc and @meta in dev-lua-doc * fixup! Co-authored-by: Justin M. Keyes <justinkz@gmail.com> --------- Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2023-07-17docs(lua): change *lua-foo* -> *vim.foo*Lewis Russell1
2023-06-22fix: tostring(vim.version()) fails if build is NIL #24097Julian Grinblat1
Problem: Since #23925, Version.build may be vim.NIL, which causes tostring() to fail: E5108: Error executing lua E5114: Error while converting print argument #1: …/version.lua:129: attempt to concatenate field 'build' (a userdata value) stack traceback: [C]: in function 'print' [string ":lua"]:1: in main chunk Solution: Handle vim.NIL in Version:__tostring().
2023-06-12feat: tostring(vim.version())Justin M. Keyes1
Problem: tostring(vim.version()) returns "table: 0x…". Solution: Modify vim.version() to return a string prerelease instead of a boolean. Fix #23863
2023-06-12feat: vim.version() returns a Version objectGianmaria Bajo1
- vim.version() returns a Version object. Makes it printable and removes the need of workarounds when passing it to other vim.version methods.
2023-06-06fix: version-range < and <= #23539Gianmaria Bajo1
vim.version.range() couldn't parse them correctly. For example, vim.version.range('<0.9.0'):has('0.9.0') returned `true`. fix: range:has() accepts vim.version() So that it's possible to compare a range with: vim.version.range(spec):has(vim.version())
2023-05-13docs: small fixesdundargoc1
Co-authored-by: Christian Clason <c.clason@uni-graz.at> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: HiPhish <hiphish@posteo.de> Co-authored-by: Julio B <julio.bacel@gmail.com> Co-authored-by: T727 <74924917+T-727@users.noreply.github.com> Co-authored-by: camoz <camoz@users.noreply.github.com> Co-authored-by: champignoom <66909116+champignoom@users.noreply.github.com>
2023-03-22refactor(vim.gsplit): remove "keepsep"Justin M. Keyes1
string.gmatch() is superior, use that instead.
2023-03-22fix(vim.version): prerelease compareJustin M. Keyes1
Problem: semver specifies that digit sequences in a prerelease string should be compared as numbers, not lexically: https://semver.org/#spec-item-11 > Precedence for two pre-release versions with the same major, minor, > and patch version MUST be determined by comparing each dot separated > identifier from left to right until a difference is found as follows: > 1. Identifiers consisting of only digits are compared numerically. > 2. Identifiers with letters or hyphens are compared lexically in ASCII sort order. > 3. Numeric identifiers always have lower precedence than non-numeric identifiers. > 4. A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal. Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0. Solution: cmp_prerel() treats all digit sequences in a prerelease string as numbers. This doesn't _exactly_ match the spec, which specifies that only dot-delimited digit sequences should be treated as numbers...
2023-03-20feat(vim.version): more coercion with strict=falseJustin M. Keyes1
Problem: "tmux 3.2a" (output from "tmux -V") is not parsed easily. Solution: With `strict=false`, discard everything before the first digit. - rename Semver => Version - rename vim.version.version() => vim.version._version() - rename matches() => has() - remove `opts` from cmp()
2023-03-20refactor(vim.version): use lazy.nvim semver moduleJustin M. Keyes1
Now the Nvim version string "v0.9.0-dev-1233+g210120dde81e" parses correctly.
2023-03-20refactor(vim.version): use lazy.nvim semver moduleJustin M. Keyes1
Use semver code from https://github.com/folke/lazy.nvim License: Apache License 2.0 Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2023-03-06fix(vim.version): incorrect version.cmp()Justin M. Keyes1
Problem: If major<major but minor>minor, cmp_version_core returns 1 Solution: - Fix logic in cmp_version_core - Delete most eq()/gt()/lt() tests, they are redundant.
2023-03-06refactor(vim.version): cleanupJustin M. Keyes1
- version.cmp(): assert valid version - add test for loading vim.version (the other tests use shared.lua in the test runner) - reduce test scopes, reword test descriptions
2023-03-06feat(lua): add semver apiKelly Lin1