aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/vim_spec.lua
Commit message (Collapse)AuthorAge
* test: check vim.wait() error message in fast context (#26242)zeertzjq2023-11-27
|
* fix(lua): disallow vim.wait() in fast contextsLewis Russell2023-11-27
| | | | | | | `vim.wait()` cannot be called in a fast callback since the main loop cannot be run in that context as it is not reentrant Fixes #26122
* fix(vim.region): handle multibyte inclusive selection properly (#26129)zeertzjq2023-11-21
|
* fix(f_wait): flush UI before blocking (#25962)zeertzjq2023-11-10
|
* fix(lua): correct return value for on_key with no arguments (#25911)altermo2023-11-07
|
* fix(lua): vim.region on linewise selection #25467Aayush Ojha2023-10-06
| | | fixes #18155
* fix(api, lua): handle setting v: variables properly (#25325)zeertzjq2023-09-24
|
* fix(lua): show error message when failing to set variable (#25321)zeertzjq2023-09-23
|
* fix(lua): not using global value in vim.opt_global (#25196)Phelipe Teles2023-09-17
|
* vim-patch:9.0.1710: scrolloff options work slightly differentzeertzjq2023-08-23
| | | | | | | | | | | | | | | | | | | | | | | Problem: sidescrolloff and scrolloff options work slightly different than other global-local options Solution: Make it behave consistent for all global-local options It was noticed, that sidescrolloff and scrolloff options behave differently in comparison to other global-local window options like 'listchars' So make those two behave like other global-local options. Also add some extra documentation for a few special local-window options. Add a few tests to make sure all global-local window options behave similar closes: vim/vim#12956 closes: vim/vim#12643 https://github.com/vim/vim/commit/4a8eb6e7a9df10f79bf95301ced012f0d6a13088 Co-authored-by: Christian Brabandt <cb@256bit.org>
* test(api): update tests to new error messagesbfredl2023-08-07
|
* fix(api/options): validate buf and winLewis Russell2023-07-22
| | | Fixes #24398
* docs: also change "vimL" and "viml" to "Vimscript" (#24414)zeertzjq2023-07-21
|
* feat(lua): allow vim.wo to be double indexed (#20288)Lewis Russell2023-07-07
| | | | | | | | * feat(lua): allow vim.wo to be double indexed Problem: `vim.wo` does not implement `setlocal` Solution: Allow `vim.wo` to be double indexed Co-authored-by: Christian Clason <c.clason@uni-graz.at>
* feat(lua): add ringbuffer (#22894)Mathias Fußenegger2023-06-08
| | | https://en.wikipedia.org/wiki/Circular_buffer
* feat(lua): rename vim.loop -> vim.uv (#22846)Lewis Russell2023-06-03
|
* test: don't unnecessarily specify win/buf for `nvim_(get|set)_option_value`Famiu Haque2023-05-22
| | | | `nvim_(get|set)_option_value` pick the current buffer / window by default for buffer-local/window-local (but not global-local) options. So specifying `buf = 0` or `win = 0` in opts is unnecessary for those options. This PR removes those to reduce code clutter.
* refactor(options): deprecate nvim[_buf|_win]_[gs]et_optionLewis Russell2023-05-21
| | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: famiu <famiuhaque@protonmail.com>
* refactor(build): include lpeg as a librarybfredl2023-04-27
|
* test: move vim.iter tests to separate fileGregory Anders2023-04-24
|
* 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(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
* 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.
* 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.
* feat(lua): vim.region accepts getpos() arg (#22635)NAKAI Tsuyoshi2023-04-11
|
* feat(lua): allow vim.F.if_nil to take multiple arguments (#22903)Gregory Anders2023-04-07
| | | | | | | | | | | | The first argument which is non-nil is returned. This is useful when using nested default values (e.g. in the EditorConfig plugin). Before: local enable = vim.F.if_nil(vim.b.editorconfig, vim.F.if_nil(vim.g.editorconfig, true)) After: local enable = vim.F.if_nil(vim.b.editorconfig, vim.g.editorconfig, true)
* refactor: rename local API alias from a to apiLewis Russell2023-04-05
| | | | | | | | Problem: Codebase inconsistently binds vim.api onto a or api. Solution: Use api everywhere. a as an identifier is too short to have at the module level.
* 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.
* 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
* fix(lua): vim.deprecate() shows ":help deprecated" #22677Justin M. Keyes2023-03-15
| | | | | | | | | | | Problem: vim.deprecate() shows ":help deprecated" for third-party plugins. ":help deprecated" only describes deprecations in Nvim, and is unrelated to any 3rd party deprecations. Solution: If `plugin` is specified, don't show ":help deprecated". fix #22235
* refactor!: rename vim.pretty_print => vim.printJustin M. Keyes2023-03-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The function name `vim.pretty_print`: 1. is verbose, which partially defeats its purpose as sugar 2. does not draw from existing precedent or any sort of convention (except external projects like penlight or python?), which reduces discoverability, and degrades signaling about best practices. Solution: - Rename to `vim.print`. - Change the behavior so that 1. strings are printed without quotes 2. each arg is printed on its own line 3. tables are indented with 2 instead of 4 spaces - Example: :lua ='a', 'b', 42, {a=3} a b 42 { a = 3 } Comparison of alternatives: - `vim.print`: - pro: consistent with Lua's `print()` - pro: aligns with potential `nvim_print` API function which will replace nvim_echo, nvim_notify, etc. - con: behaves differently than Lua's `print()`, slightly misleading? - `vim.echo`: - pro: `:echo` has similar "pretty print" behavior. - con: inconsistent with Lua idioms. - `vim.p`: - pro: very short, fits with `vim.o`, etc. - con: not as discoverable as "echo" - con: less opportunity for `local p = vim.p` because of potential shadowing.
* feat(lua): omnifunc for builting lua interpreterBjörn Linse2023-03-06
| | | | | | | also make implicit submodules "uri" and "_inspector" work with completion this is needed for `:lua=vim.uri_<tab>` wildmenu completion to work even before uri or _inspector functions are used.
* refactor(api): VALIDATE macros #22187Justin M. Keyes2023-02-14
| | | | | | | | | Problem: - API validation involves too much boilerplate. - API validation errors are not consistently worded. Solution: Introduce some macros. Currently these are clumsy, but they at least help with consistency and avoid some nesting.
* 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>
* test: avoid noise in NVIM_LOG_FILEJustin M. Keyes2023-01-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Tests that _intentionally_ fail certain conditions cause noise in $NVIM_LOG_FILE: $NVIM_LOG_FILE: /home/runner/work/neovim/neovim/build/.nvimlog (last 100 lines) WRN 2023-01-16T18:26:27.673 T599.7799.0 unsubscribe:519: RPC: ch 1: tried to unsubscribe unknown event 'doesnotexist' WRN 2023-01-16T18:29:00.557 ?.11151 server_start:163: Failed to start server: no such file or directory: /X/X/X/... WRN 2023-01-16T18:33:07.269 127.0.0.1:12345 server_start:163: Failed to start server: address already in use: 127.0.0.1 ... -- Output to stderr: module 'vim.shared' not found: no field package.preload['vim.shared'] no file './vim/shared.lua' no file '/home/runner/nvim-deps/usr/share/lua/5.1/vim/shared.lua' no file '/home/runner/nvim-deps/usr/share/lua/5.1/vim/shared/init.lua' no file '/home/runner/nvim-deps/usr/lib/lua/5.1/vim/shared.lua' no file '/home/runner/nvim-deps/usr/lib/lua/5.1/vim/shared/init.lua' no file './vim/shared.so' ... E970: Failed to initialize builtin lua modules Solution: - Log to a private $NVIM_LOG_FILE in tests that intentionally fail and cause ERR log messages. - Assert that the expected messages are actually logged.
* 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.
* fix: vim.opt_local:append ignoring global option value (#21382)Phelipe Teles2022-12-12
| | | Closes https://github.com/neovim/neovim/issues/18225
* feat(aucmd_win): allow crazy things with hidden buffers (#21250)zeertzjq2022-12-02
| | | | Problem: Crash when doing crazy things with hidden buffers. Solution: Dynamically allocate the list of autocommand windows.
* docs: fix typos (#21196)dundargoc2022-11-29
| | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Raphael <glephunter@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com>
* fix(lua): make `vim.deepcopy` work with `vim.NIL`Max2022-11-14
| | | | | | | | style: changed double quotes to single quotes feat: add tests fix tests
* feat(test): add Lua forms for API methods (#20152)Lewis Russell2022-11-14
|
* 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>
* docs: fix typos (#20724)dundargoc2022-10-23
| | | Co-authored-by: Marco Lehmann <m99@posteo.de>
* fix(lua): on_yank error with blockwise multibyte region #20162Daniel Zhang2022-10-14
| | | | | Prevent out of range error when calling `str_byteindex`. Use `vim.str_byteindex(bufline, #bufline)` to cacluate utf length of `bufline`. fix #20161
* fix(lua): assert failure with vim.regex() error inside :silent! (#20555)RZia2022-10-10
| | | Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* docs: fix typos (#20394)dundargoc2022-09-30
| | | | | Co-authored-by: Raphael <glephunter@gmail.com> Co-authored-by: smjonas <jonas.strittmatter@gmx.de> Co-authored-by: zeertzjq <zeertzjq@outlook.com>