aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/shared.lua
Commit message (Collapse)AuthorAge
* docs: misc #24561Justin M. Keyes2023-09-20
| | | | fix #24699 fix #25253
* docs: replace <pre> with ``` (#25136)Gregory Anders2023-09-14
|
* fix(lua): improve annotations for stricter luals diagnostics (#24609)Christian Clason2023-08-09
| | | | | | | | | | | | | | | 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
* docs: luaref cleanup #24541Justin M. Keyes2023-08-03
| | | | - drop "luaref-" prefix in favor of "lua-" or nothing, where possible. - remove redundant "luaref--lang…" and "luaref-api…" tags.
* 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: fix vim.tbl_get type annotations #23992Stanislav Asunkin2023-06-11
|
* feat(lua): add ringbuffer (#22894)Mathias Fußenegger2023-06-08
| | | https://en.wikipedia.org/wiki/Circular_buffer
* docs: small fixesdundargoc2023-05-13
| | | | | | | | | 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>
* 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(lua): simplify vim.gsplit implJustin M. Keyes2023-04-21
|
* fix(lua): vim.split may trim inner empty itemsJustin M. Keyes2023-04-21
| | | | | | | | | | Problem: `vim.split('a:::', ':', {trimempty=true})` trims inner empty items. Regression from 9c49c1047079427ff0a2356cb37302934845108e Solution: Set `empty_start=false` when first non-empty item is found. close #23212
* 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.
* feat(lua)!: add stricter vim.tbl_islist() and rename old one to ↵NAKAI Tsuyoshi2023-04-14
| | | | | | | | | | | | vim.tbl_isarray() (#16440) feat(lua)!: add stricter vim.tbl_islist(), rename vim.tbl_isarray() Problem: `vim.tbl_islist` allows gaps in tables with integer keys ("arrays"). Solution: Rename `vim.tbl_islist` to `vim.tbl_isarray`, add new `vim.tbl.islist` that checks for consecutive integer keys that start from 1.
* feat(lua): vim.tbl_contains supports general tables and predicates (#23040)Christian Clason2023-04-14
| | | | | | | | | | | | * feat(lua): vim.tbl_contains supports general tables and predicates Problem: `vim.tbl_contains` only works for list-like tables (integer keys without gaps) and primitive values (in particular, not for nested tables). Solution: Rename `vim.tbl_contains` to `vim.list_contains` and add new `vim.tbl_contains` that works for general tables and optionally allows `value` to be a predicate function that is checked for every key.
* refactor: remove modelines from Lua filesGregory Anders2023-04-13
| | | | Now that we have builtin EditorConfig support and a formatting check in CI, these are not necessary.
* docs: fix typosdundargoc2023-04-04
| | | | | | Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Raphael <glephunter@gmail.com> Co-authored-by: C.D. MacEachern <craig.daniel.maceachern@gmail.com> Co-authored-by: himanoa <matsunoappy@gmail.com>
* feat: allow function passed to defaulttable to take an argument (#22839)Gregory Anders2023-04-01
| | | | Pass the value of the key being accessed to the create function, to allow users to dynamically generate default values.
* refactor(vim.gsplit): remove "keepsep"Justin M. Keyes2023-03-22
| | | | string.gmatch() is superior, use that instead.
* fix(vim.version): prerelease compareJustin M. Keyes2023-03-22
| | | | | | | | | | | | | | | | | | | | 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...
* feat(vim.gsplit): gain features of vim.splitJustin M. Keyes2023-03-22
| | | | | | | | | | | | | Problem: - vim.split has more features than vim.gsplit. - Cannot inspect the "separator" segments of vim.split or vim.gsplit. Solution: - Move common implementation from vim.split into vim.gsplit. - TODO: deprecate vim.split in favor of vim.totable(vim.gsplit())? - Introduce `keepsep` parameter. Related: 84f66909e4008a57da947f1640bfc24da5e41a72
* docs(lua): number → integer (#22517)Jaehwang Jung2023-03-04
|
* build: make generated source files reproducible #21586Arnout Engelen2023-01-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Build is not reproducible, because generated source files (.c/.h/) are not deterministic, mostly because Lua pairs() is unordered by design (for security). https://github.com/LuaJIT/LuaJIT/issues/626#issuecomment-707005671 https://www.lua.org/manual/5.1/manual.html#pdf-next > The order in which the indices are enumerated is not specified [...] > >> The hardening of the VM deliberately randomizes string hashes. This in >> turn randomizes the iteration order of tables with string keys. Solution: - Update the code generation scripts to be deterministic. - That is only a partial solution: the exported function (funcs_metadata.generated.h) and ui event (ui_events_metadata.generated.h) metadata have some mpack'ed tables, which are not serialized deterministically. - As a workaround, introduce `PRG_GEN_LUA` cmake setting, so you can inject a modified build of luajit (with LUAJIT_SECURITY_PRN=0) that preserves table order. - Longer-term we should change the mpack'ed data structure so it no longer uses tables keyed by strings. Closes #20124 Co-Authored-By: dundargoc <gocdundar@gmail.com> Co-Authored-By: Arnout Engelen <arnout@bzzt.net>
* docs(lua): use luaref tag instead of www.lua.org #21813Naru2023-01-15
|
* docs(lua): adjust some type annotationsnotomo2023-01-04
|
* docs(lua): fix treesitter parsing errorsChristian Clason2023-01-01
|
* fix(lua): always return nil values in vim.tbl_get when no resultsWilliam Boman2022-12-15
| | | | | | | | | | | | | | | | | | | While `return` and `return nil` are for most intents and purposes identical, there are situations where they're not. For example, calculating the amount of values via the `select()` function will yield varying results: ```lua local function nothing() return end local function null() return nil end select('#', nothing()) -- 0 select('#', null()) -- 1 ``` `vim.tbl_get` currently returns both nil and no results, which makes it unreliable to use in certain situations without manually accounting for these discrepancies.
* docs(gen): support language annotation in docstringsChristian Clason2022-12-02
|
* fix(lua): make `vim.deepcopy` work with `vim.NIL`Max2022-11-14
| | | | | | | | style: changed double quotes to single quotes feat: add tests fix tests
* fix(lua): pesc, tbl_islist result types #20751NAKAI Tsuyoshi2022-10-24
| | | | | | | | | | | | Problem: - pesc() returns multiple results, it should return a single result. - tbl_islist() returns non-boolean in some branches. - Docstring: @generic must be declared first Solution: Constrain docstring annotations. Fix return types. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(docs-html): update parserJustin M. Keyes2022-10-10
| | | | | | | | | | | - Improve generated HTML by updating parser which includes fixes for single "'" and single "|": https://github.com/neovim/tree-sitter-vimdoc/pull/31 - Updated parser also fixes the conceal issue for "help" highlight queries https://github.com/neovim/tree-sitter-vimdoc/issues/23 by NOT including whitespace in nodes. - But this means we need to restore the getws() function which scrapes leading whitespace from the original input (buffer).
* fix(lua): properly configure luacheck and remove `local vim = ...` lines ↵Folke Lemaitre2022-10-09
| | | | (#20551)
* feat: added support for specifying types for lua2doxFolke Lemaitre2022-10-06
|
* feat: added support for optional params to lua2doxFolke Lemaitre2022-10-06
|
* docs: added proper annotations to functions in shared.luaFolke Lemaitre2022-10-06
|
* docs(docstrings): fix runtime type annotationsElizabeth Paź2022-10-05
|
* fix(docs): invalid :help links #20345Justin M. Keyes2022-09-25
| | | | | Fix those naughty single quotes. closes #20159
* docs(treesitter): clean up and update treesitter.txt (#20142)Christian Clason2022-09-14
| | | | | * add type annotations to code * clean up and expand static documentation * consistent use of tags for static and generated docs
* Use weak tables in tree-sitter code (#17117)Thomas Vigouroux2022-09-07
| | | | | | feat(treesitter): use weak tables when possible Also add the defaulttable function to create a table whose values are created when a key is missing.
* docs(lua): add Lua 5.1 reference manual (#19663)dundargoc2022-08-08
| | | | | | | | based on http://www.vim.org/scripts/script.php?script_id=1291 reformatted to match Nvim documentation style; removed irrelevant sections Co-authored-by: dundargoc <gocundar@gmail.com> Co-authored-by: Christian Clason <c.clason@uni-graz.at> Co-authored-by: Lewis Russell <lewis6991@gmail.com>
* refactor(lua): reformat with stylua 0.14.0 (#19264)Christian Clason2022-07-07
| | | | * reformat Lua runtime to make lint CI pass * reduce max line length to 100
* docs(api): improve shared lua functions docs (#17933)adrian52022-05-11
|
* chore: format runtime with styluaChristian Clason2022-05-09
|
* fix(shared): avoid indexing unindexable values in vim.tbl_get() (#18337)William Boman2022-05-01
|
* feat: add vim.tbl_get (#17831)Michael Lingelbach2022-03-24
| | | | | | vim.tbl_get takes a table with subsequent string arguments (variadic) that index into the table. If the value pointed to by the set of keys exists, the function returns the value. If the set of keys does not exist, the function returns nil.
* chore: fix typos (#17670)dundargoc2022-03-17
| | | Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* refactor(lua): make vim submodule lazy loading declarativebfredl2022-03-07
| | | | | This will allow us to also use the same logic for lua threads and processes, later.
* docs(lua): reference runtime/lua/vim/_editor.luazeertzjq2022-03-06
|
* fix(diagnostic): improve validation for list arguments (#16855)Gregory Anders2022-01-01
| | | | | | Function arguments that expect a list should explicitly use tbl_islist rather than just checking for a table. This helps catch some simple errors where a single table item is passed as an argument, which passes validation (since it's a table), but causes other errors later on.
* feat(lua): add support for multiple optional types in vim.validate (#16864)Shadman2022-01-01
|