aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/autocmd_spec.lua
Commit message (Collapse)AuthorAge
* test: simplify functional test expectationsLewis Russell2026-10-05
| | | | | | | | | | | | Problem: Repeated default fields and field-by-field assertions obscure the values that each functional test is meant to check. Solution: Add eq_partial() to check selected record fields while preserving list length and order. Use local helpers to fill fixed expected defaults where tests need full equality. Keep explicit absence checks and test-specific values at the call sites. AI-assisted
* feat(api): add ev.win to autocmd callback args #39826glepnir2026-09-09
| | | | | | | | Problem: Autocmd callbacks currently have to rely on curwin, which may already have changed by the time they run. This is especially noticeable for WinNew, WinClosed, WinResized and WinScrolled. Solution: Track the window in the autocmd context and expose it as ev.win. Pass it explicitly for the window events that need it.
* fix(api): do not pull a fast one for nvim_del_augroup_by_idbfredl2026-09-08
| | | | | | | | This is a bit more boilerplate because of painful impedance mismatch (is augroup names the root source of truth? is ids the source of truth? who knows? what does truth even mean?), but show an error reflecting what the caller actually tried (they passed in an invalid id, not a null string)
* test: fix wrong order of args to eq(), neq() #41499zeertzjq2026-08-26
|
* test(harness): migrate away from magic globalsJustin M. Keyes2026-07-21
| | | | | | | | | | | | | | | | | | | | | Problem: The magic globals `it`, `describe`, etc., are more trouble than they are worth. - Hooking into `after_each` requires `getfenv()` hacks. - They confuse luals/emmylua, because the top-level `.luarc.json` isn't merged with `test/.luarc.json` (apparently a luals limitation?) - They totally defeat discoverability because the user just has to "know" about the various magic symbols. So they harm DX, which means they serve no purpose at all. Solution: - Expose the test API from `testutil`, so tests can call `t.it()`, `t.describe()`, etc., in the conventional way. - Drop `getfenv()` hacks. - Drop the `setfenv()` injection in `load_chunk`. - Drop `test/_meta.lua`.
* fix(autocmd): no cleanup for redraw curwin change #40389luukvbaal2026-06-24
| | | | | | Problem: Unecessary/unexpected cleanup happens when restoring the current window for redraw purposes (since 28ffb334). Solution: Don't call autocmd_restbuf() to restore the current window, just do so directly.
* fix(api): nvim_exec_autocmds({buf=x}) runs in buffer context #39061Barrett Ruth2026-05-20
| | | | | Problem: `nvim_exec_autocmds({ buf = ... })` matches the target buffer, but callbacks and modelines run with the caller buffer current rather than the target buffer. Solution: Execute the buffered path in prepared target-buffer context and restore the caller afterward.
* feat(api): rename buffer to buf in retval #38900Justin M. Keyes2026-04-13
| | | | | | In 3a4a66017b74192caaf9af9af172bdc08e0c1608, 4d3a67cd620152d11ab9b5f5bdd973f84cc2d44b we renamed "buffer" to "buf" in dict parameters. This commit also renames such keys in dict return-values.
* feat(api): rename buffer to buf #35330Jordan2026-04-08
| | | | | | | | | | | | Problem: `:help dev-name-common` states that "buf" should be used instead of "buffer" but there are cases where buffer is mentioned in the lua API. Solution: - Rename occurrences of "buffer" to "buf" for consistency with the documentation. - Support (but deprecate) "buffer" for backwards compatibility. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(api)!: nvim_clear_autocmds() "event" handlingSean Dewar2026-04-08
| | | | | | | | | | | | | | | Problem: nvim_clear_autocmds() does not type check "event" correctly, and also treats an empty array "event" like nil. Solution: fix type checking. Treat empty array "event" as a no-op, like nvim_exec_autocmds(). Add some extra tests. Likewise the nil handling change may be considered breaking if anyone (unintentionally) relied on that. It was also true that integer, function, etc. "event"s would also be treated like nil! Note that an empty string "event" is still an error, as that's must be an exact match on an event name.
* docs(api): nvim_exec_autocmds() default "pattern"Sean Dewar2026-04-08
| | | | | | | Problem: nvim_exec_autocmds() documentation incorrectly describes the default for "pattern" as *, when it's actually the current file name (like :doautocmd). Solution: correct it. Add a test.
* fix(api)!: empty non-nil autocmd "pattern" handlingSean Dewar2026-04-08
| | | | | | | | | | Problem: in autocmd APIs, a non-nil "pattern" containing only empty 'sub'-patterns is silently treated as nil, causing the fallback value to be unexpectedly used instead. Solution: for nvim_create_autocmd(), raise a validation error (as no autocmds would be created). For nvim_{exec,clear}_autocmds(), make it a no-op (as matching no autocmds is not an error).
* docs: api, lsp, messages, intro #38327Justin M. Keyes2026-03-17
|
* docs: use "ev" convention in event-handlersJustin M. Keyes2026-03-12
| | | | | | | | | Problem: In autocmd examples, using "args" as the event-object name is vague and may be confused with a user-command. Solution: Use "ev" as the conventional event-object name.
* test: remove a few more redundant clear() calls (#35903)zeertzjq2025-09-24
|
* feat(api): nvim_get_autocmds filter by id#31549glepnir2025-01-26
| | | | | | | Problem: nvim_get_autocmds cannot filter by id. Solution: Support it.
* fix(events): don't expand `args.file` for Lua callback (#31473)zeertzjq2024-12-06
| | | | | | | | Problem: In an autocommand Lua callback whether `args.file` is expanded depends on whether `expand('<afile>')` has been called. Solution: Always use the unexpanded file name for `args.file`. Related to #31306 and vim/vim#16106. This doesn't provide `sfname`, but at least makes `args.file` have a consistent value.
* 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.
* fix(lua): only free luarefs when returning from API (#28373)zeertzjq2024-04-17
|
* test: getting autocmd Lua callback in Vimscript (#28367)zeertzjq2024-04-16
| | | Also remove unnecessary variable in API converter.
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* test: rename (meths, funcs) -> (api, fn)Lewis Russell2024-01-12
|
* test: normalise nvim bridge functionsLewis Russell2024-01-12
| | | | | - remove helpers.cur*meths - remove helpers.nvim
* test: typing for helpers.methsLewis Russell2024-01-12
|
* refactor: format test/*Justin M. Keyes2024-01-03
|
* docs: small fixes (#25585)dundargoc2023-10-29
| | | | Co-authored-by: tmummert <doczook@gmx.de> Co-authored-by: parikshit adhikari <parikshitadhikari@gmail.com>
* fix(autocmd): API functions accept garbage after event name #25523ii142023-10-09
| | | | | | | "VimEnter foo" was accepted as a valid event name for "VimEnter". Events delimited with commas, eg. "VimEnter,BufRead", were also accepted, even though only the first event was actually parsed. Co-authored-by: ii14 <ii14@users.noreply.github.com>
* test(api): update tests to new error messagesbfredl2023-08-07
|
* fix(events): don't expand non-file as file namezeertzjq2023-06-07
|
* fix(api): avoid assertion when autocmd group id is 0 (#23210)Dhruv Manilawala2023-04-23
|
* Merge #22214 move init_default_autocmds to luaJustin M. Keyes2023-02-14
|\
| * refactor: move init_default_autocmds to luaglacambre2023-02-11
| | | | | | | | | | | | | | | | | | The original motivation for this change came from developping https://github.com/neovim/neovim/pull/22159, which will require adding more autocommand creation to Neovim's startup sequence. This change requires lightly editing a test that expected no autocommand to have been created from lua.
* | refactor(api): consistent VALIDATE messages #22262Justin M. Keyes2023-02-14
| | | | | | | | | | | | | | | | | | | | Problem: Validation messages are not consistently formatted. - Parameter names sometimes are NOT quoted. - Descriptive names (non-parameters) sometimes ARE quoted. Solution: Always quote the `name` value passed to a VALIDATE macro _unless_ the value has whitespace.
* | refactor(api): VALIDATE macros #22256Justin M. Keyes2023-02-14
| | | | | | | | | | | | - VALIDATE() takes a format string - deduplicate check_string_array - VALIDATE_RANGE - validate UI args
* | 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.
* fix(api): nvim_create_autocmd crash on invalid types inside pattern arrayii142023-01-12
| | | Co-authored-by: ii14 <ii14@users.noreply.github.com>
* docs #20986Justin M. Keyes2022-12-11
| | | | | | - https://github.com/neovim/tree-sitter-vimdoc v1.2.4 eliminates most errors in pi_netrw.txt, so we can remove that workaround from ignore_parse_error(). - improved codeblock
* feat(api): support pattern array for exec_autocmdsChristian Clason2022-06-26
|
* feat(autocmds): retrieve lua callback (#18642)kylo2522022-06-09
| | | add a new `callback` field to `nvim_get_autocmds`
* fix(autocmds): separate command from desc (#18617)kylo2522022-05-21
|
* feat(api): enable nvim_exec_autocmds to pass arbitrary data (#18613)Gregory Anders2022-05-18
| | | | Add a "data" key to nvim_exec_autocmds that passes arbitrary data (API objects) to autocommand callbacks.
* feat(api): add `group_name` to `nvim_get_autocmds`Famiu Haque2022-05-05
|
* test: correct order of arguments to eq() and neq()zeertzjq2022-04-26
|
* feat(api)!: pass args table to autocommand callbacksGregory Anders2022-04-08
|
* Merge pull request #17938 from ggandor/autocmd-api-namesbfredl2022-04-01
|\ | | | | refactor(api)!: use singular/plural consistently in the autocmd API
| * refactor(api)!: use singular/plural consistently in the autocmd APIGyörgy Andorka2022-03-31
| |
* | Merge pull request #17929 from lewis6991/autocmdbfredl2022-03-31
|\ \ | |/ |/| fix(api): improve autocmd error handling
| * fix(api): improve autocmd error handlingLewis Russell2022-03-31
| | | | | | | | | | - nvim_del_augroup_* now works with pcall - nvim_del_autocmd now errors for invalid ids
* | feat(api): nvim_clear_autocmdTJ DeVries2022-03-31
|/ | | | Co-authored-by: Christian Clason <christian.clason@uni-due.de>