aboutsummaryrefslogtreecommitdiff
path: root/test/functional/options
Commit message (Collapse)AuthorAge
* fix(options): reject restricted assignments before parsing callbacksLewis Russell2026-09-24
| | | | | | | | | | | | | | | | | | Problem: A restricted option assignment parses its callback before rejecting the change. A Syntax handler triggered by a modeline can therefore evaluate bound arguments even though the option cannot be changed. Introduced by 726d1a92d2. That change moved callback construction from did_set_operatorfunc(), after the permission check, into validation and storage, before did_set_option() checks permissions. Solution: Check permissions before parsing the callback, preserving the existing option value without evaluating the rejected expression. AI-assisted
* fix(options): avoid crash for shell paths ending in a separator #41882Volodymyr Chernetskyi2026-09-12
| | | | | | | | | | | Problem: A trailing separator in 'shell' leaves the parsed end before the path tail. The resulting length underflows and crashes option initialization. Solution: Reset the end pointer when advancing past a separator, preserving quoted path parsing. Cover a trailing separator at startup. AI-assisted
* fix(cwd): stale buffer names after temp context-switch #41433Justin M. Keyes2026-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: 1. `ctx_dirs_restore()` is the only chdir site that doesn't re-shorten buffer names; `post_chdir()`, `update_cwd()` and `do_autochdir()` all call `shorten_fnames(true)`. So after a temp window-context switch that moved the CWD, every buffer's `b_fname` is still relative to the other directory. ui2 renders messages in a float, and entering it is such a switch, so with a `:bcd` in a `BufReadPost` handler 'statusline' "%f" shows ".config/nvim/init.lua" while the CWD is already `~/.config/nvim`, and :write resolves the name against it: ``` E212: Can't open file for writing: no such file or directory ``` 2. `msg_multihl()` leaves `msg_ext_id` pointing at the caller's storage when nothing was emitted (e.g. 'msg_silent'): the reset only ran on a flush that produced chunks. The next message then ships a dead stack frame as its msg_show id. After ":silent write" the id is buf_write()'s `msg_id[MAXPATHL + 32]`: ``` id = "\0\0\0\0\0\0\0\0\29\0(<C6>k\24R\17p<C7><C7><C7>\1\0\0\0..." ``` Solution: 1. `shorten_fnames(true)` after restoring the CWD. Drop `cs_save_sfname`, which was a partial workaround for the same bug. 2. Release the id in `msg_multihl()`, where it is set and the caller's frame is still alive. Stop reading `.data.integer` out of a String union member.
* fix(options): ":set foo?" for Lua callbacks #41100Justin M. Keyes2026-08-01
| | | | | | | | | | | | | | | | | Problem: `:set foo=<tab>` and `:set foo?` for func/expr options set to a Lua function, always displays "v:lua". The existing "<Lua N: file:line>" form was avoided because the ref id N changes on every read of the same option. Solution: - Don't attempt to tab-complete Lua functions. - Show "<Lua file:line>" (or "<Lua>" if source file is unknown). Example: :set operatorfunc? operatorfunc=<Lua ~/.config/nvim/init.lua:42>
* refactor(options): memory managementJustin M. Keyes2026-07-31
| | | | | | | | | | | | | | | | Problem: Numerous callers have to manually check optval ownership (i.e. whether, and how, to release) via `is_callback_option`, `option_is_global_local`, etc. This is fragile, hard to use correctly; and if we introduce another optval variant in the future, we'll have to redo all of these careful checks and boilerplate again. Solution: Provide a unified system and use it everywhere: optval_free_owned optval_is_owned optval_own
* feat(options): lua closure/function optionsJustin M. Keyes2026-07-31
| | | | | | | | | | | | | | | Problem: Cannot assign Lua functions/closures to "func" ('completefunc', 'tagfun', …) or "expr" ('foldexpr', 'indentexpr', …) options. Solution: - Store "func"/"expr" options as `Callback` instead of string. - Delete oceans of copy-pasted code. - BREAKING: LuaRef returned via RPC/Vimscript is now represented as `"<Lua N: file:line>"` (like what `:map` shows) instead of `nil`. - Note: `man.vim` still uses `v:lua` string, bc it's a vimscript ftplugin. Helped-by: Lewis Russell <lewis6991@gmail.com>
* refactor(options): store dict options in :set-string formJustin M. Keyes2026-07-24
| | | | | | | | | | The parent commit made a valiant effort to store "dict options" in their reified form, but this is more trouble than it's worth: - inconsistent model for developers to understand. - string lifetime issues (the "varp" convention is to pass around an aliased, long-lived option value). - lots of extra plumbing to deal with the 2 different option-storage paradigms.
* feat(options): schema, "dict" options, messagesJustin M. Keyes2026-07-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Options parsing is still painful for dict-style options. Solution: schema-maxxing => better `opt:get()` (will be the basis for `vim.o()`), unified (and more-detailed) err msgs. - Drop bespoke structure-builder in `_core/options.lua`. - Define `schema` for all non-primitive options (except 'guicursor' and statusline-style options); generate reified keysets `OptKeyDict`). - Generate 'fillchars' => `fcs_tab`, 'listchars' => `lcs_tab`. - `nvim_set_option_value`: - Return the improved structures. Also from `vim.opt.x:get()`. - Eliminate api <=> lua roundtrip, centralize option structure handling. - Improve/unify errors. - Bump ERR_BUFLEN 80 → 256 so the "one of" list isn't truncated. - Eliminate old 'diffopt' order-dependence (`iwhiteall` before `iwhite`) Error samples: Typed-key path (opt_strings_check → diffopt/mousescroll/breakindentopt): E474: Unknown item 'foo' E474: 'context' requires a number E474: 'ver' number is out of range E474: 'algorithm' must be one of: myers, minimal, patience, histogram E474: 'filler' does not take a value Related: - #31084 - #34661 - #31820 - #14739 - #20107 - fix #18875 - :get() returns `{ sbr = true, shift = '3' }` (reified-keyset) instead of `{'sbr', 'shift:3'}` - Setting via table now works too. `object_as_optval_for` `is_map` now recognizes struct options. - fix #30296 - instead of `E474: Invalid argument`, errors now look like: ``` E474: Invalid value 'x', expected one of: single, double: ambiwidth=x E474: Unknown item 'foo': diffopt=foo E474: 'context' requires a number: diffopt=context:x ``` simplify `win_float_parse_option` from #26799.
* 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`.
* test: unreliable "bumps 'busy' on each watched buffer" #40804Justin M. Keyes2026-07-18
| | | | | | | | Problem: Sampling a transient busy=1 pulse is racy under load. Solution: Set a long debounce, assert the stable state, then use a short debounce to let the reload clear it.
* test: unreliable "bumps 'busy' on each watched buffer" #40794Justin M. Keyes2026-07-17
| | | | | | | | | Problem: Test still unreliable. Solution: Don't require both 'busy' pulses to coincide. followup to #40775
* test: unreliable "bumps 'busy' on each watched buffer" #40775Justin M. Keyes2026-07-16
|
* fix(path): normalize separators (slashes) #39155tao2026-07-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Continue separators normalization, and try to keep it at the nvim <-> external boundary, e.g., `fn.xxx`, `api.xxx`, `:xxx` Solution: some key changes - normalize `$HOME-windows` - normalize entry points of changing directory - `nvim_set_current_dir()`, `chdir()` - normalize the named pipe - `--listen` arg, `--server` arg, `:restart` - `serverstart()`, `sockconnect()`, `serverstop()` - make `expand()` respect 'shellslash' again - clean up `did_set_shellslash` - replace `forward_slash` with `TO_SLASH` - remove obsolete `TMP_PATHSEPSTR` - remove `slash_adjust` in `do_autocmd_dirchanged`? - make `fnamemodify()` always return `/` (except when substituting separators via `:s`, `:gs` ?) Note: - these funcs still apply `slash_adjust` on return, as before: `:pwd`, `chdir()`, `exepath()`, `getcwd()` - these funcs alwarys return `/`, unlike before the normalization PRs - `getcompletion()`, `finddir()`, `findfile()` Also - clean up code, comments, formatting and tests - move `TO_SLASH` from `f_chdir` to `changedir_func` - move `TO_SLASH` from `f_bufadd` to `buflist_new` Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* test(autoread): unreliable "coalesces rapid changes via debouncing"Justin M. Keyes2026-07-12
| | | | | | | | | | | | | previous: #40272 FAILED …/autoread_spec.lua @ 142: autoread file watcher coalesces rapid changes via debouncing Expected values to be equal. Expected: 1 Actual: 2 stack traceback: …/autoread_spec.lua:169: in function <…/autoread_spec.lua:142>
* fix(socket): --listen silently truncates long paths #40625MAAZIZ Adel Ayoub2026-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: A `--listen` path longer than the system socket path limit (~104 bytes on macOS, 108 on Linux) is silently truncated by `uv_pipe_bind()`. Nvim either serves a socket at a different path than `v:servername` reports, or fails with an error that blames the full untruncated path (confusing): nvim: Failed to --listen: address already in use: "<full path>" Steps to reproduce: $ nvim --listen /var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T//nvim/-Users-rpatterson-Projects-src-github.com-neovide-neovide --embed -p nvim: Failed to --listen: address already in use: "/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T//nvim/-Users-rpatterson-Projects-src-github.com-neovide-neovide" $ ls /var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T//nvim/-Users-rpatterson-Projects-src-github.com-neovide-neovide "/var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T//nvim/-Users-rpatterson-Projects-src-github.com-neovide-neovide": No such file or directory (os error 2) $ ls -l /var/folders/g7/9y_ydbnj2fs_fvp8xf44p8gc0000gn/T//nvim/ srwxr-xr-x@ - rpatterson 31 Mar 10:24 -Users-rpatterson-Projects-src-github.com-neovid Solution: Bind with `uv_pipe_bind2()` and `UV_PIPE_NO_TRUNCATE` (libuv 1.46+), so a too-long path fails up front with the actual reason: nvim: Failed to --listen: invalid argument: "<full path>"
* test: unreliable "stdpath() avoids DOS 8.3 filenames" #40574Justin M. Keyes2026-07-04
| | | | | | | | | | | | | | | Problem: FAILED …/defaults_spec.lua @ 1286: stdpath() avoids DOS 8.3 filenames for "cache" and "run" Expected values to be equal. Expected: "XTEST_~1" Actual: "XTEST_~2" stack traceback: …/defaults_spec.lua:1296: in function <…/defaults_spec.lua:1286> Solution: Relax the test.
* test(autoread): unreliable "coalesces rapid changes via debouncing" #40272Justin M. Keyes2026-06-15
|
* fix(autoread): handle autocmd errorsJustin M. Keyes2026-06-14
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: Any random ftplugin or other autocmd, can throw an error when `:checktime` reloads a buffer. This causes a trace which makes it look like an issue with `autoread.lua`. vim.schedule callback: …/runtime/lua/nvim/autoread.lua:146: FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[20] ..script …/runtime/ftplugin/help.lua: Vim(runtime):E5113: Lua chunk: …/runtime/lua/vim/treesitter.lua:216: Index out of bounds stack traceback: [C]: in function 'nvim_buf_get_text' …/runtime/lua/vim/treesitter.lua:216: in function 'get_node_text' …/runtime/lua/vim/treesitter/query.lua:558: in function 'handler' …/runtime/lua/vim/treesitter/query.lua:843: in function '_match_predicates' …/runtime/lua/vim/treesitter/query.lua:1082: in function '(for generator)' …/runtime/ftplugin/help.lua:91: in function 'runnables' …/runtime/ftplugin/help.lua:124: in main chunk [C]: in function 'checktime' …/runtime/lua/nvim/autoread.lua:146: in function <…/runtime/lua/nvim/autoread.lua:138> Solution: Use pcall() and surface the error via nvim_echo.
* feat(autoread): surface autoread activity via 'busy' flagJustin M. Keyes2026-06-14
| | | | | | | | | | | | | | | | Problem: Old 'autoread' only did `:checktime` on focus-change and shell (":!") commands, and only for non-hidden buffers. Since 'autoread' is now driven by OS filewatcher events, buffers are updated much more eagerly. This should be surfaced to the user somehow, either via a carefully placed notification, or a minimal UI indicator. A "notification" would be noisy, unless it is conditional on specific circumstances (e.g. when "many" buffers are updated). Solution: Use the existing 'busy' buffer-local option as a subtle hint about activity.
* test(autoread): make "debounce" test actually validJustin M. Keyes2026-06-13
|
* test(autoread): cleanupJustin M. Keyes2026-06-13
| | | | | | - Merged into the main "reloads on external change" test. - Reduce duplication. - Wall-clock down from ~4.4s to ~1.4s (dropped 3s debounce test).
* feat(autoread): use filewatchers for OS-driven change detection #37971Oleksandr Chekhovskyi2026-06-12
| | | | | | | | | | | | | | | Problem: The 'autoread' option only checks for file changes reactively — on FocusGained, :checktime, CmdlineEnter, etc. — by polling timestamps. External changes are not detected until the user interacts with Neovim. Solution: Add a core module (runtime/lua/nvim/autoread.lua) enabled from runtime/plugin/autoread.lua that watches each buffer's file using vim._watch.watch() (libuv fs_event). On change detection it calls :checktime, which invokes the existing buf_check_timestamp() logic for reload/prompt handling. Watchers are managed via autocmds tied to buffer lifecycle events and respect the 'autoread' option (global and buffer-local).
* fix(stdpath): avoid DOS 8.3 filenames for "cache", "run" #40201tao2026-06-12
| | | | | | | | | | | | Problem: stdpath() may return a DOS 8.3 "shortened" filename, because Windows truncates long usernames into `6ch~N` names in `TEMP/TMP` env vars. We don't want to "leak" them into Nvim. Solution: For "run", pass `true` to `vim_FullName` to expand 8.3 filenames. For "cache", call `os_realpath` to expand 8.3 filenames. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* docs: miscJustin M. Keyes2026-06-11
|
* fix(option): set 'shell…' options based on detected shell #40031tao2026-06-10
| | | | | | | | | | | | | | | | | | Problem: * 'shellcmdflag' states that its default value is set according to the value of 'shell', but this behavior is not yet implemented on Windows. The same applies to 'shellpipe', 'shellredir', and 'shellxquote'. * On Windows, Git is often installed in paths containing spaces, and we still do not correctly resolve the sh executable name as described in 'shell'. * On Windows, the default value of 'shellslash' is always `false`, which causes Unix-like shells to interpret `\` in paths returned by some functions as escape charaters. Solution: Use a simple rule table to detect common shells (e.g. `cmd`, `powershell`, shells whose names contain `csh` or `sh`) and apply best-effort defaults, while leaving more complex scenarios to user configuration.
* docs: misc #39256Justin M. Keyes2026-04-25
|
* fix(path): normalize path slashes on Windows #37729tao2026-04-24
| | | | | | | | | | | | | | | | | | | | Problem: On Windows, path separators may become inconsistent for various reasons, which makes normalization quite painful. Solution: Normalize paths to `/` at the entry boundaries and always use it internally, converting back only in rare cases where `\` is really needed (e.g. cmd.exe/bat scripts?). This is the first commit in a series of incremental steps. Note: * some funcs won't respect shellslash. e.g. `expand/fnamemodify` * some funcs still respect shellslash, but will be updated in a follow PR. e.g. `ex_pwd/f_chdir/f_getcwd` * uv's built-in funcs always return `\`. e.g. `uv.cwd/uv.exepath` Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* refactor(test): drop deprecated exc_exec #39242Justin M. Keyes2026-04-20
|
* feat(logs)!: move logs to `stdpath("state")/logs`Olivia Kinnear2026-04-09
|
* test: start test runners in Xtest_xdg dir (#37964)zeertzjq2026-02-20
| | | | | | | | | | | | | | This is a better way to prevent parallel tests from interfering with each other, as there are many ways files can be created and deleted in tests, so enforcing different file names is hard. Using $TMPDIR can also work in most cases, but 'backipskip' etc. have special defaults for $TMPDIR. Symlink runtime/, src/, test/ and README.md to Xtest_xdg dir to make tests more convenient (and symlinking test/ is required for busted). Also, use README.md instead of test/README.md in the Ex mode inccommand test, as test/README.md no longer contains 'N' char.
* feat(logging): rename ".nvimlog" => "nvim.log" #37935Justin M. Keyes2026-02-18
| | | | | | - Rename ".nvimlog" to "nvim.log" - doesn't need to be "hidden"/dotfile - ".log" extension helps with filetype detection - Also rename "nvim/log" => "nvim/nvim.log"
* feat(defaults): exclude temp dirs from 'shada' oldfiles #37631Pavel Pisetski2026-02-03
| | | | | | | | | | Problem: Temporary files from /tmp/ and /private/ paths clutter :oldfiles list. Additionally, the documented Windows default (rA:,rB:) was never applied due to a missing platform condition. Solution: Drop platform-specific shada differences and default to excluding /tmp/ and /private/ paths.
* refactor(test): use command, pcall_err in num_options_spec #36933glepnir2025-12-15
| | | | | | Problem: feed_command is marked as deprecated, and validating error messages is a bit verbose. Solution: use command and pcall_err with matches
* test: remove a few more redundant clear() calls (#35903)zeertzjq2025-09-24
|
* feat(messages): cleanup Lua error messagesJustin M. Keyes2025-05-04
| | | | | "Error" in error messages is redundant. Just provide the context, don't say "Error ...".
* test: multiline assert_log()Justin M. Keyes2025-05-04
| | | | | | | | | | | | | Problem: assert_log() only matches single lines. This was never an intentional decision, it was merely a result of using read_file_list(). Note: any tests that indiscriminately match `.*` should be rewritten to avoid (unlikely) "false positives". I checked all existing tests. Solution: Change assert_log() to match the concatenated lines instead of matching per-line.
* docs: misc #31996Justin M. Keyes2025-03-02
|
* test: use spawn_wait() instead of system() #31852Justin M. Keyes2025-01-04
| | | | | | | | | | | Problem: Tests that need to check `nvim` CLI behavior (no RPC session) create their own ad-hoc `system()` wrappers. Solution: - Use `n.spawn_wait` instead of `system()`. - Bonus: this also improves the tests by explicitly checking for `stdout` or `stderr`. And if a signal is raised, `ProcStream.status` will reflect it.
* fix(api): not using TRY_WRAP, generic error messages #31595Justin M. Keyes2024-12-16
| | | | | | | | | | | Problem: - API functions using `try_start` directly instead of `TRY_WRAP`, do not surface the underlying error message, and instead show generic things like "Failed to set buffer". - Error handling code is duplicated in the API impl, instead of delegating to the vim buffer/window handling logic. Solution: - Use `TRY_WRAP`.
* fix(api): nvim_win_set_buf(0, 0) fails if 'winfixbuf' is set #31576phanium2024-12-16
| | | | | | | | | | | | ## Problem With 'winfixbuf' enabled, `nvim_win_set_buf` and `nvim_set_current_buf` fail even if targeting the already-current buffer. vim.wo.winfixbuf = true vim.api.nvim_win_set_buf(0, 0) vim.api.nvim_set_current_buf(0) Solution: Check for this condition.
* 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(options): fix some 'belloff' flags not working properly (#30856)zeertzjq2024-10-18
| | | | Problem: Some 'belloff' flags don't work properly. Solution: Keep BO_ flags and p_bo_values[] in sync.
* fix(test): "tempdir not a directory" in CI logsJustin M. Keyes2024-09-09
| | | | | | $NVIM_LOG_FILE: /Users/runner/work/neovim/neovim/build/.nvimlog WRN 2024-09-08T21:48:13.279 ?.21134 vim_mktempdir:3281: $TMPDIR tempdir not a directory (or does not exist): TMPDIR-should-be-ignored WRN 2024-09-08T21:48:13.312 ?.21137 vim_mktempdir:3281: $TMPDIR tempdir not a directory (or does not exist): TMPDIR-should-be-ignored
* refactor(test): rename alter_slashes, invert its behaviorJustin M. Keyes2024-09-09
| | | | | | | - `alter_slashes` belongs in `testutil.lua`, not `testnvim.lua`. - `alter_slashes` is an unusual name. Rename it to `fix_slashes`. - invert its behavior, to emphasize that `/` slashes are the preferred, pervasive convention, not `\` slashes.
* fix(startup): server fails if $NVIM_APPNAME is relative dir #30310Justin M. Keyes2024-09-08
| | | | | | | | | | | | | | | | | | Problem: If $NVIM_APPNAME is a relative dir path, Nvim fails to start its primary/default server, and `v:servername` is empty. Root cause is d34c64e342dfba9248d1055e702d02620a1b31a8, but this wasn't noticed until 96128a5076b7 started reporting the error more loudly. Solution: - `server_address_new`: replace slashes "/" in the appname before using it as a servername. - `vim_mktempdir`: always prefer the system-wide top-level "nvim.user/" directory. That isn't intended to be specific to NVIM_APPNAME; rather, each *subdirectory* ("nvim.user/xxx") is owned by each Nvim instance. Nvim "apps" can be identified by the server socket(s) stored in those per-Nvim subdirs. fix #30256
* feat(defaults): popupmenu "Open in browser", "Go to definition" #30261Justin M. Keyes2024-09-05
| | | | - Use the popup to expose more features such as LSP and gx. - Move the copy/paste items lower in the menu, they are lower priority.
* feat(startup): validate --listen addressJustin M. Keyes2024-09-02
| | | | | | | | | | | | | Problem: `nvim --listen` does not error on EADDRINUSE. #30123 Solution: Now that `$NVIM_LISTEN_ADDRESS` is deprecated and input *only* (instead of the old, ambiguous situation where it was both an input *and* an output), we can be fail fast instead of trying to "recover". This reverts the "recovery" behavior of 704ba4151e7f67999510ee0ac19fdabb595d530c, but that was basically a workaround for the fragility of `$NVIM_LISTEN_ADDRESS`.
* 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.
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.