aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/iter.lua
Commit message (Collapse)AuthorAge
* docs: support inline markdownLewis Russell2024-03-09
| | | | | | - Tags are now created with `[tag]()` - References are now created with `[tag]` - Code spans are no longer wrapped
* fix(types): move type annotation for `IterMod`Will Hopkins2024-03-06
|
* refactor(types): more fixes (2)Lewis Russell2024-03-06
|
* docs: improve/add documentation of Lua typesLewis Russell2024-03-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* feat(docs): replace lua2dox.luaLewis Russell2024-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* docs(vim.iter): correct `bool` to `boolean` (#27018)notomo2024-01-18
|
* fix(doc): improve doc generation of types using lpegLewis Russell2024-01-11
| | | | Added a lpeg grammar for LuaCATS and use it in lua2dox.lua
* feat(vim.iter): add Iter:flatten (#26786)JD2024-01-10
| | | | | Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Jongwook Choi <wookayin@gmail.com>
* refactor: fix luals warningsdundargoc2023-12-30
|
* feat(iter): add `Iter.take` (#26525)Will Hopkins2023-12-12
|
* feat(lua): implement Iter:join() (#26416)Gregory Anders2023-12-05
|
* docs: vim.iter #26169Justin M. Keyes2023-11-25
| | | | closes #24141 closes #24746
* feat(vimdoc): support Markdown code blocks (#25127)Gregory Anders2023-09-13
| | | | | | Support Markdown code blocks in addition to <pre> blocks in Doxygen doc comments. Update doc comments in iter.lua as a test.
* fix(iter): make pipeline termination conditions consistent (#24614)Gregory Anders2023-08-09
| | | | | | | | If an iterator pipeline stage returns nil as its first return value, the other return values are ignored and it is treated as if that stage returned only nil (the semantics of returning nil are different between different stages). This is consistent with how for loops work in Lua more generally, where the for loop breaks when the first return value from the function iterator is nil (see :h for-in for details).
* docs: miscJustin M. Keyes2023-08-03
| | | | Co-authored-by: Kevin Pham <keevan.pham@gmail.com>
* docs(lua): more improvements (#24387)Lewis Russell2023-07-18
| | | | | | | | | | | | | | | | | * 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>
* docs(lua): change *lua-foo* -> *vim.foo*Lewis Russell2023-07-17
|
* fix(docs): vimdoc syntax errorsJustin M. Keyes2023-06-25
| | | | gen_help_html: truncate parse-error sample text
* docs #22363Justin M. Keyes2023-06-19
| | | | | | | | | Co-authored by: zeertzjq <zeertzjq@outlook.com> Co-authored by: Steven Todd McIntyre II <114119064+stmii@users.noreply.github.com> Co-authored by: nobe4 <nobe4@users.noreply.github.com> - docs: mention --luadev-mod to run with lua runtime files When changing a lua file in the ./runtime folder, a new contributor might expect changes to be applied to the built Neovim binary.
* feat(lua): use callable table as iterator in vim.iter (#23957)Mathias Fußenegger2023-06-10
| | | | A table passed to `vim.iter` can be a class instance with a `__call` implementation for the iterator protocol.
* perf(iter): make ListIter.totable more efficient (#23714)Lewis Russell2023-06-03
|
* docs(iter): add emmylua type to iter module (#23845)Sebastian Lyng Johansen2023-06-03
|
* docs: small fixes (#23619)dundargoc2023-06-02
| | | | | | Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com> Co-authored-by: Gustavo Ferreira <gustavo.ferreira@imaginecurve.com> Co-authored-by: Kai Moschcau <mail@kmoschcau.de> Co-authored-by: Lampros <hauahx@gmail.com>
* perf(iter): reduce number of table allocationsGregory Anders2023-04-28
| | | | | | | | Packing and unpacking return values impairs performance considerably. In an attempt to avoid creating tables as much as possible we can instead pass return values between functions (which does not require knowing the number of values a function might return). This makes the code more complex, but improves benchmark numbers non-trivially.
* refactor(iter): move helper functions under vim.iterGregory Anders2023-04-25
| | | | vim.iter is now both a function and a module (similar to vim.version).
* refactor(iter): use metatable as packed table tag (#23254)Gregory Anders2023-04-21
| | | | | This is a more robust method for tagging a packed table as it completely eliminates the possibility of mistaking an actual table key as the packed table tag.
* fix(iter): remove special case totable for map-like tablesGregory Anders2023-04-19
| | | | | | | | | | | | | | | | | | | | | | | This was originally meant as a convenience but prevents possible functionality. For example: -- Get the keys of the table with even values local t = { a = 1, b = 2, c = 3, d = 4 } vim.iter(t):map(function(k, v) if v % 2 == 0 then return k end end):totable() The example above would not work, because the map() function returns only a single value, and cannot be converted back into a table (there are many such examples like this). Instead, to convert an iterator into a map-like table, users can use fold(): vim.iter(t):fold({}, function(t, k, v) t[k] = v return t end)
* fix(iter): add tag to packed tableGregory Anders2023-04-19
| | | | | | | | | | | | | | | If pack() is called with a single value, it does not create a table; it simply returns the value it is passed. When unpack is called with a table argument, it interprets that table as a list of values that were packed together into a table. This causes a problem when the single value being packed is _itself_ a table. pack() will not place it into another table, but unpack() sees the table argument and tries to unpack it. To fix this, we add a simple "tag" to packed table values so that unpack() only attempts to unpack tables that have this tag. Other tables are left alone. The tag is simply the length of the table.
* feat(lua): add vim.iter (#23029)Gregory Anders2023-04-17
vim.iter wraps a table or iterator function into an `Iter` object with methods such as `filter`, `map`, and `fold` which can be chained to produce iterator pipelines that do not create new tables at each step.