aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/vim_spec.lua
Commit message (Collapse)AuthorAge
* docs: misc #31867Justin M. Keyes2025-01-09
|
* fix(api): generic error messages, not using TRY_WRAP #31596Justin M. Keyes2024-12-16
| | | | | | | | | | | Problem: - API functions using `try_start` directly, do not surface the underlying error message, and instead show generic messages. - Error-handling code is duplicated in the API impl. - Failure modes are not tested. Solution: - Use `TRY_WRAP`. - Add tests.
* fix(messages)!: vim.ui_attach message callbacks are unsafeLuuk van Baal2024-11-14
| | | | | | | | Problem: Lua callbacks for "msg_show" events with vim.ui_attach() are executed when it is not safe. Solution: Disallow non-fast API calls for "msg_show" event callbacks. Automatically detach callback after excessive errors. Make sure fast APIs do not modify Nvim state.
* fix(tests): needing two calls to setup a screen is cringebfredl2024-11-14
| | | | | | | | | | Before calling "attach" a screen object is just a dummy container for (row, col) values whose purpose is to be sent as part of the "attach" function call anyway. Just create the screen in an attached state directly. Keep the complete (row, col, options) config together. It is still completely valid to later detach and re-attach as needed, including to another session.
* fix(lua): show stacktrace for error in vim.on_key() callback (#31021)zeertzjq2024-11-02
|
* feat(lua): allow vim.on_key() callback to consume the key (#30939)errael2024-11-01
|
* feat(stdlib): overload vim.str_byteindex, vim.str_utfindex #30735Tristan Knight2024-10-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PROBLEM: There are several limitations to vim.str_byteindex, vim.str_utfindex: 1. They throw given out-of-range indexes. An invalid (often user/lsp-provided) index doesn't feel exceptional and should be handled by the caller. `:help dev-error-patterns` suggests that `retval, errmsg` is the preferred way to handle this kind of failure. 2. They cannot accept an encoding. So LSP needs wrapper functions. #25272 3. The current signatures are not extensible. * Calling: The function currently uses a fairly opaque boolean value to indicate to identify the encoding. * Returns: The fact it can throw requires wrapping in pcall. 4. The current name doesn't follow suggestions in `:h dev-naming` and I think `get` would be suitable. SOLUTION: - Because these are performance-sensitive, don't introduce `opts`. - Introduce an "overload" that accepts `encoding:string` and `strict_indexing:bool` params. ```lua local col = vim.str_utfindex(line, encoding, [index, [no_out_of_range]]) ``` Support the old versions by dispatching on the type of argument 2, and deprecate that form. ```lua vim.str_utfindex(line) -- (utf-32 length, utf-16 length), deprecated vim.str_utfindex(line, index) -- (utf-32 index, utf-16 index), deprecated vim.str_utfindex(line, 'utf-16') -- utf-16 length vim.str_utfindex(line, 'utf-16', index) -- utf-16 index vim.str_utfindex(line, 'utf-16', math.huge) -- error: index out of range vim.str_utfindex(line, 'utf-16', math.huge, false) -- utf-16 length ```
* feat(vim.validate): improve fast form and deprecate spec formLewis Russell2024-10-21
| | | | | | | | | | | | | | Problem: `vim.validate()` takes two forms when it only needs one. Solution: - Teach the fast form all the features of the spec form. - Deprecate the spec form. - General optimizations for both forms. - Add a `message` argument which can be used alongside or in place of the `optional` argument.
* test(rpc): retry flaky 'vim.rpcrequest and vim.rpcnotify' testChristian Clason2024-10-21
| | | | | | Problem: 'vim.rpcrequest and vim.rpcnotify' is flaky on Windows. Solution: retry it.
* fix(lua): vim.deprecate does not support major>0Justin M. Keyes2024-10-21
|
* fix(lua): avoid recursive vim.on_key() callback (#30753)zeertzjq2024-10-12
|
* refactor(lua): vim.keymap.set tests, docs #30511Justin M. Keyes2024-09-25
|
* refactor(api)!: rename Dictionary => DictJustin M. Keyes2024-09-23
| | | | | | | | | | | | | | In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not (in practice) a breaking change.
* fix(lua): revert vim.tbl_extend behavior change and document itChristian Clason2024-09-08
| | | | | | | | | | | | | | Problem: vim.tbl_deep_extend had an undocumented feature where arrays (integer-indexed tables) were not merged but compared literally (used for merging default and user config, where one list should overwrite the other completely). Turns out this behavior was relied on in quite a number of plugins (even though it wasn't a robust solution even for that use case, since lists of tables (e.g., plugin specs) can be array-like as well). Solution: Revert the removal of this special feature. Check for list-like (contiguous integer indices) instead, as this is closer to the intent. Document this behavior.
* test(lua): tbl_deep_extend "after second argument" #30297Justin M. Keyes2024-09-07
|
* fix(lua): allows tables with integer keys to be merged in tbl_deep_extendLewis Russell2024-09-04
| | | | | | | | | - The exclusion of lists was never justified in the commit history and is the wrong thing to do for a function that deals with tables. - Move the error checks out of the recursive path. Fixes #23654
* docs: misc #28970Justin M. Keyes2024-09-01
|
* refactor(tests): again yet more global highlight definitionsbfredl2024-08-14
|
* fix(lua)!: do not use typed table for empty dictAmit Singh2024-07-13
| | | | | | | | | | | | | | | | | Problem: Empty dictionaries are converted into typed tables of the form `{ [true] = 6}` instead of an empty dictionary representation `{}`. This leads to incorrect table representation, along with failure in JSON encoding of such tables as currently tables with only string and number type keys can be encoded. Solution: The typed table logic has been removed from `nlua_push_Dictionary`. The typed table logic is required only for float value conversions which is already handled in `nlua_push_Float`. So, it is(was) no longer required here. Fixes neovim/neovim#29218
* fix(lua): use rawget() to get __call in vim.is_callable() (#29536)Tyler Miller2024-07-04
| | | | | Lua 5.1 uses a "raw get" to retrieve `__call` from a metatable to determine if a table is callable. Mirror this behavior in `vim.is_callable()`.
* test: fix vim.deprecate testsLewis Russell2024-06-12
|
* fix(vim.wo): never allow non-zero bufnrLewis Russell2024-06-12
|
* perf: add fast path to vim.validate (#28977)Gregory Anders2024-05-27
| | | | | | For many small/simple functions (like those found in shared.lua), the runtime of vim.validate can far exceed the runtime of the function itself. Add an "overload" to vim.validate that uses a simple assertion pattern, rather than parsing a full "validation spec".
* fix: change deprecation presentationdundargoc2024-05-24
| | | | | | | | | | | | | | Deprecation with vim.deprecate is currently too noisy. Show the following warning instead: [function] is deprecated. Run ":checkhealth vim.deprecated" for more information. The important part is that the full message needs to be short enough to fit in one line in order to not trigger the "Press ENTER or type command to continue" prompt. The full information and stack trace for the deprecated functions will be shown in the new healthcheck `vim.deprecated`.
* fix(test): failure after version bump #28771Justin M. Keyes2024-05-16
| | | | | | | | | Problem: - The test for vim.deprecate() has a "mock" which is outdated because vim.deprecate() no longer uses that. - The tests get confused after a version bump. Solution: Make the tests adapt to the current version.
* test: improve test conventionsdundargoc2024-04-23
| | | | | | | | | Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
* perf(lua): faster vim.deprecate() #28470Evgeni Chasnovski2024-04-23
| | | | | | | | | | | | Problem: `vim.deprecate()` can be relatively significantly slower than the deprecated function in "Nvim" plugin. Solution: Optimize checks for "Nvim" plugin. This also results into not distinguishing "xxx-dev" and "xxx" versions when doing checks, which is essentially covered by the deprecation logic itself. With this rewrite I get the times from #28459: `{ 0.024827, 0.003797, 0.002024, 0.001774, 0.001703 }`. For quicker reference: - On current Nightly it is something like `{ 3.72243, 0.918169, 0.968143, 0.763256, 0.783424 }`. - On 0.9.5: `{ 0.002955, 0.000361, 0.000281, 0.000251, 0.00019 }`.
* refactor(lua): rename tbl_isarray => isarrayJustin M. Keyes2024-04-21
| | | | | | | tbl_isarray was not released yet, so it will not go through a deprecation cycle. ref #24572
* refactor(lua): rename tbl_islist => islistJustin M. Keyes2024-04-21
| | | | ref #24572
* feat(lua): enable(enable:boolean, filter:table) #28374Justin M. Keyes2024-04-18
| | | | | | | | | | | | | Problem: We need to establish a pattern for `enable()`. Solution: - First `enable()` parameter is always `enable:boolean`. - Update `vim.diagnostic.enable()` - Update `vim.lsp.inlay_hint.enable()`. - It was not released yet, so no deprecation is needed. But to help HEAD users, it will show an informative error. - vim.deprecate(): - Improve message when the "removal version" is a *current or older* version.
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* feat(lua): pass keys before mapping to vim.on_key() callback (#28098)zeertzjq2024-03-31
| | | Keys before mapping (i.e. typed keys) are passed as the second argument.
* test: add a bit more testing for vim.on_key() (#28095)zeertzjq2024-03-29
| | | | | Also: - Don't use NUMBUFLEN as buffer length as its unrelated. - Restore accidentally removed comment from last commit.
* test: correct order of arguments to eq() (#27816)zeertzjq2024-03-11
|
* vim-patch:8.2.3862: crash on exit with EXITFREE and using win_execute()Sean Dewar2024-03-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Crash on exit with EXITFREE and using win_execute(). Solution: Also save and restore tp_topframe. (issue vim/vim#9374) https://github.com/vim/vim/commit/dab17a0689a2f31f69f428975f84b0c3c7ba3030 Couldn't repro the crash in the test, but I only care about this patch so switch_win sets topframe properly for win_split_ins in nvim_open_win and nvim_win_set_config. Add a test using nvim_win_call and :wincmd, as I couldn't repro the issue via nvim_open_win or nvim_win_set_config (though it's clear they're affected by this patch). That said, at that point, could just use {un}use_tabpage inside switch_win instead, which also updates tp_curwin (though maybe continue to not set it in restore_win). That would also fix possible inconsistent behaviour such as: :call win_execute(w, "let curwin_nr1 = tabpagewinnr(1)") :let curwin_nr2 = tabpagewinnr(1) Where it's possible for curwin_nr1 != curwin_nr2 if these commands are run from the 1st tabpage, but window "w" is in the 2nd (as the 1st tabpage's tp_curwin may still be invalid). I'll probably PR a fix for that later in Vim. Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor(lua): use Arena when converting from lua stack to API argsbfredl2024-02-13
| | | | | | | | | | | | and for return value of nlua_exec/nlua_call_ref, as this uses the same family of functions. NB: the handling of luaref:s is a bit of a mess. add api_luarefs_free_XX functions as a stop-gap as refactoring luarefs is a can of worms for another PR:s. as a minor feature/bug-fix, nvim_buf_call and nvim_win_call now preserves arbitrary return values.
* refactor(tests): get channel id via nvim_get_chan_info #27441Justin M. Keyes2024-02-12
| | | Minor "best practices" nudge.
* fix(eval): properly support checking v:lua function in exists() (#27124)Raphael2024-01-22
|
* fix(vim.deprecate): show deprecation warning in devel versions as wellJongwook Choi2024-01-19
| | | | | | | | | | | | | | | | | | Problem: On devel(nightly) versions, deprecation warnings for hard-deprecated features are not being displayed. E.g., - to be removed in: 0.11 - hard-deprecation since 0.10 - soft-deprecation since 0.9 then 0.10-nightly (0.10.0-dev) versions as well as 0.10.0 (stable) should display the deprecation warning message. Solution: Improve the code and logic on `vim.deprecate()`, and improve test cases with mocked `vim.version()`.
* test: use integers for API Buffer/Window/Tabpage EXT typesLewis Russell2024-01-16
|
* test: rename (meths, funcs) -> (api, fn)Lewis Russell2024-01-12
|
* test: typing for helpers.methsLewis Russell2024-01-12
|
* test: do not inject vim module into global helpersLewis Russell2024-01-12
|
* refactor: format test/*Justin M. Keyes2024-01-03
|
* feat(vim.deprecate): only issue warning if neovim version is high enoughdundargoc2023-12-25
| | | | | | | | | | | | As specified by MAINTAIN.md, features should be soft deprecated at first (meaning no warnings) to give people a chance to adjust. The problem with this approach is that deprecating a feature becomes harder than usual as during the soft deprecation period you need to remember not to issue a warning, and during the hard deprecation period you need to remember to start issuing a warning. This behavior is only enforced if the `plugin` parameter is `nil` as plugins may not want this specific behavior.
* fix(lua): memory leak when using invalid syntax with exists() (#26530)zeertzjq2023-12-12
|
* feat(eval): exists() function supports checking v:lua functions (#26485)Raphael2023-12-12
| | | | Problem: Vimscript function exists() can't check v:lua functions. Solution: Add support for v:lua functions to exists().
* test: avoid repeated screen lines in expected stateszeertzjq2023-12-09
| | | | | | This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g
* test: check vim.wait() error message in fast context (#26242)zeertzjq2023-11-27
|