aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
Commit message (Collapse)AuthorAge
* fix(vim.hl): nvim_buf_del_extmark on invalid buffer #33331phanium2025-04-05
| | | | | | | Problem: nvim_buf_del_extmark error if buffer is destroyed before timer stops Solution: check nvim_buf_is_valid.
* test(lua/hl_spec): fix hang on exit with ASAN (#33298)zeertzjq2025-04-04
|
* feat(vim.hl): allow multiple timed highlights simultaneously #33283Siddhant Agarwal2025-04-03
| | | | | | | | | Problem: Currently vim.hl.range only allows one timed highlight. Creating another one, removes the old one. Solution: vim.hl.range now returns a timer and a function. The timer keeps track of how much time is left in the highlight and the function allows you to clear it, letting the user decide what to do with old highlights.
* test(lua/secure_spec): fix failure with long path (#33280)zeertzjq2025-04-03
| | | Ref #33278
* refactor(diagnostic)!: remove deprecated diagnostic APIs (#33072)Gregory Anders2025-03-26
|
* fix: temporarily disable 0.12 deprecation testsJustin M. Keyes2025-03-26
| | | | Re-enable these after release.
* fix(lua): no omni/cmdline completion for vim.env (#33044)Phạm Bình An2025-03-26
| | | | | | | | Problem: - `:lua vim.env.<Tab>` does not show completion of environment variables - Meanwhile, `:let $<Tab>` does show completion of environment variables Solution: - Fix it
* fix(cmdline): cmdline completion of _defer_require() modules #33007phanium2025-03-24
| | | | | | | | | | | Problem: `:lua vim.lsp.c<tab>` does not list vim.lsp.completion in the completion list after 24cea4c7f7417c7fe99a98a0487f51dd68c4f409. Solution: - Always include `vim.lsp._submodule` keys in candidates. - Fixes `vim.lsp.c<tab>` -> `vim.lsp.completion`. - Eager-load `vim.lsp.completion` to get its completion. - Fixes `vim.lsp.completion.g<tab>` -> `vim.lsp.completion.get`.
* test(log): use tempfile for expected error logs #33017luukvbaal2025-03-23
|
* fix(log): unify error messages for vim.ui_attach/decor providers #33005luukvbaal2025-03-21
| | | | | | | Problem: Error messages that cause a vim.ui_attach() namespace to detach are not visible in the message history. Decoration provider and vim.ui_attach error messages are dissimilar. Solution: Emit vim.ui_attach() errors as an actual message in addition to logging it. Adjust error message format.
* fix(messages): incorrect error message splitting and kind #32990luukvbaal2025-03-19
| | | | | | | | | Problem: Message kind logic for emitting an error message is convoluted and still results in emitting an unfinished message earlier than wanted. Solution: Ensure emsg_multiline() always sets the kind wanted by the caller and doesn't isn't unset to logic for emitting the source message. Caller is responsible for making sure multiple message chunks are not emitted as multiple events by setting `msg_ext_skip_flush`...
* fix(snippet): wrong indentation when snippet contains "^" #32970Avinash Thakur2025-03-19
| | | | | | | | | | | | | | | | | | | | | | | ## Problem The pattern used to match indentation is wrong as can be seen in ```lua -- current pattern doesn't match starting space print(vim.inspect((" xyz"):match("(^%s+)%S"))) -- nil -- instead, it matches characters `^ ` in text print(vim.inspect(("x^ yz"):match("(^%s+)%S"))) -- "^ " -- indentation could've been matched by, however not required print(vim.inspect((" xyz"):match("^(%s+)%S"))) -- " " ``` ## Solution We don't even need to modify `base_indent` at every line. If every line's indentation is calculated by the previous line's indentation (which already has starting indentation) added to the starting indentation, we see that indentation is multiplied on every line. Hence, we only add the starting line indentation to every line.
* fix(filetype): normalize full path before matching #32227markstegeman2025-03-19
| | | | | | | | | | | | | Problem: On Windows, treesitter query files are not recognized as such when opened from inside their directory, because the full path returned from fnamemodify(_, ':p') contains backslashes, while the filetype patterns expect forward slashes. Solution: Normalize the result of fnamemodify(_, ':p') before trying to match it to filetype patterns. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(lua): ensure inspect_pos() only shows visible highlight extmarksLuuk van Baal2025-03-18
| | | | | | | | | | | | | | | Problem: Unpaired marks are shown with `filter.extmarks == true`, which should only return visible highlights. Misleading `end_col` included in `inspect_pos()` for unpaired mark; it is set to `start_col + 1` which would be a visible highlight, which it is not. Custom "is_here" filter used to get extmarks overlapping a position. Solution: Exclude unpaired highlight extmarks with `filter.extmarks == true`. Set `end_col` to `start_col` for an unpaired mark. Supply appropriate arguments to nvim_buf_get_extmarks() to return overlapping extmarks; exclude marks whose end is at `{row, col}` with `filter.extmarks == true`.
* refactor(test): move runtime_spec.lua to editor/ #32919Justin M. Keyes2025-03-16
| | | | | | | | Problem: The `lua/` tests dir is for Lua stdlib tests. It is not for anything that randomly happens to be implemented with Lua. Solution: Move `lua/runtime_spec.lua` to `editor/runtime_spec.lua`.
* test: flaky loop_spec.lua #32885Justin M. Keyes2025-03-14
| | | | | | | | | | | | | | | | | | | | Problem: Test may fail because it matches a Lua table address, and the following whitespace may differ depending on the stringified address length: test/functional/lua/loop_spec.lua:233: Row 3 did not match. Expected: |{3: }| |{9:Error executing callback:} | |*{9:uv_idle_t: 0x{MATCH:%w+}} | |{6:Press ENTER or type command to continue}^ | Actual: |{3: }| |{9:Error executing callback:} | |*{9:uv_idle_t: 0xd4c2820a00} | |{6:Press ENTER or type command to continue}^ | Solution: Match a variable amount of whitespace.
* feat(snippet): set snippet keymaps permanent instead of dynamic (#31887)Mathias Fußenegger2025-03-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Given that `vim.snippet.expand()` sets temporary `<tab>`/`<s-tab>` keymaps there is no way to build "smart-tab" functionality where `<tab>` chooses the next completion candidate if the popup menu is visible. Solution: Set the keymap permanent in `_defaults`. The downside of this approach is that users of multiple snippet engine's need to adapt their keymaps to handle all their engines that are in use. For example: vim.keymap.set({ 'i', 's' }, "<Tab>", function() if foreign_snippet.active() then return "<Cmd>lua require('foreign_snippet').jump()<CR>" elseif vim.snippet.active({ direction = 1 }) then return "<Cmd>lua vim.snippet.jump(1)<CR>" else return key end end, { expr = true }) Upside is that using `vim.keymap.set` to override keymaps is a well established pattern and `vim.snippet.expand` calls made by nvim itself or plugins have working keymaps out of the box. Co-authored-by: Maria José Solano <majosolano99@gmail.com>
* fix(lua): vim.hl.on_yank highlights wrong region with yi' (#32850)phanium2025-03-13
| | | | | | | Problem: yi' don't highlight last character since https://github.com/neovim/neovim/commit/8ce504820af04194a41acbe1f4c61cf12bd5feb5. Solution: Always use `opts.inclusive=true`, since calculation of `"]` (`b_op_end`) have taken `inclusive` into account.
* feat(defaults): jump between :terminal shell prompts with ]]/[[ #32736Gregory Anders2025-03-07
|
* fix(lua): always use vim.inspect() for :lua= (#32715)zeertzjq2025-03-07
|
* fix(lua): format errors from luv callbacks using __tostringbfredl2025-03-05
|
* fix(diagnostic): virtual_lines diagnostic columns (#32703)James Trew2025-03-04
| | | | | When multiple diagnostics appear on a single line, the virtual lines for all diagnostics except the first were rendered with progressively fewer columns.
* docs: misc #31996Justin M. Keyes2025-03-02
|
* feat(lua): don't complete private (_) fields after dot (.) #32690Maria José Solano2025-03-02
|
* feat(comment): allow commentstring to be determined from node metadataRiley Bruins2025-03-02
| | | | | | | | | | | **Problem:** Some weird languages have different comment syntax depending on the location in the code, and we do not have a way to determine the correct `commentstring` for these special cases. **Solution:** Allow queries to specify `commentstring` values in metadata, allowing users/`nvim-treesitter` to provide a better commenting experience without hugely increasing the scope of the code in core.
* vim-patch:8.2.4603: sourcing buffer lines is too complicatedzeertzjq2025-02-28
| | | | | | | | | | | | | | | | | | | | | | | | Problem: Sourcing buffer lines is too complicated. Solution: Simplify the code. Make it possible to source Vim9 script lines. (Yegappan Lakshmanan, closes vim/vim#9974) https://github.com/vim/vim/commit/85b43c6cb7d56919e245622f4e42db6d8bee4194 This commit changes the behavior of sourcing buffer lines to always have a script ID, although sourcing the same buffer always produces the same script ID. vim-patch:9.1.0372: Calling CLEAR_FIELD() on the same struct twice Problem: Calling CLEAR_FIELD() on the same struct twice. Solution: Remove the second CLEAR_FIELD(). Move the assignment of cookie.sourceing_lnum (zeertzjq). closes: vim/vim#14627 https://github.com/vim/vim/commit/f68517c1671dfedcc1555da50bc0b3de6d2842f6 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* feat(lua): vim.text.indent()Justin M. Keyes2025-02-26
| | | | | | | | | | | | | Problem: Indenting text is a common task in plugins/scripts for presentation/formatting, yet vim has no way of doing it (especially "dedent", and especially non-buffer text). Solution: Introduce `vim.text.indent()`. It sets the *exact* indentation because that's a more difficult (and thus more useful) task than merely "increasing the current indent" (which is somewhat easy with a `gsub()` one-liner).
* fix(lua): don't override script ID from :source (#32626)zeertzjq2025-02-25
| | | | | | | | Problem: When setting an option, mapping etc. from Lua without -V1, the script ID is set to SID_LUA even if there already is a script ID assigned by :source. Solution: Don't set script ID to SID_LUA if it is already a Lua script. Also add _editor.lua to ignorelist to make script context more useful when using vim.cmd().
* fix(lua): SIGSEGV in luv callback with error(nil) #32595phanium2025-02-24
| | | | | | | | | Problem: luv callback `vim.uv.new_timer():start(0, 0, function() error() end)` causes SIGSEGV, since `xstrdup` gets NULL from `lua_tostring`. Similar to: https://github.com/neovim/neovim/commit/a5b1b83a2693ffa7a5a0a22b3693d36ea60051be Solution: Check NULL before `xstrdup`.
* test(lua/hl_spec): fix hang on exit with ASAN (#32508)zeertzjq2025-02-18
|
* test(lua/hl_spec): reduce flakiness (#32489)zeertzjq2025-02-17
|
* fix(memline): don't check line count for closed memline #32403luukvbaal2025-02-12
| | | | | | Problem: Error thrown when for invalid line number which may be accessed in an `on_detach` callback at which point line count is intentionally set to 0. Solution: Move empty memline check to before line number check.
* fix(lua): vim.tbl_get({}, nil, 1) should return nil #32218phanium2025-02-09
| | | | | | | | | | | | | | | Problem: `vim.tbl_get(tbl, nil, 1)` returns `tbl` itself. In this case, `keys` is not empty, but `ipairs` skips the iteration: local keys = { nil, 1 } assert(#keys == 2) for i, k in ipairs(keys) do assert(false, 'unreachable') end Solution: Use `select("#", ...)` and `select(i, ...)` to ensure consistency for count and iteration.
* feat(diagnostic): add `current_line` option for `virtual_text` handlerMaria José Solano2025-02-05
|
* feat(diagnostic): format() can filter diagnostics by returning nil #32302Maria José Solano2025-02-03
|
* fix(ui): avoid redundant ext_cmdline events (#32237)luukvbaal2025-01-29
| | | | | | | | Problem: `cmdline_show` is emitted unnecessarily each event loop iteration, because `cmdline_was_last_drawn` is never set. Solution: Keep track of whether the cmdline was last drawn to avoid unnecessarily emitting cmdline_show. Set `redraw_state` to emit `cmdline_pos` when emitting `CursorMovedC`. Only emit `cmdline_pos` when cmdline was last drawn.
* feat(diagnostic): virtual_lines #31959Maria José Solano2025-01-26
|
* fix(lua): pop retval for fast context LuaRefLuuk van Baal2025-01-24
| | | | | | Problem: nlua_call_ref_ctx() does not pop the return value in fast context that did not error. Solution: Fall through to end; calling nlua_call_pop_retval().
* fix(messages): avoid empty msg_showmode with 'noshowmode'Luuk van Baal2025-01-24
|
* test(lua/hl_spec): set timeout for transient state (#32169)zeertzjq2025-01-23
|
* feat(lua): vim.hl.range() "timeout" #32012Siddhant Agarwal2025-01-22
| | | | | | | | Problem: `vim.hl.on_yank()` has a "timeout" behavior but this is not available for `vim.hl.range()`. Solution: Add `timeout` arg to `vim.hl.range()`.
* vim-patch:9.1.1030: filetype: setting bash filetype is backwards incompatibleChristian Clason2025-01-20
| | | | | | | | | | | | | | | | | | | | | | | | Problem: filetype: setting bash filetype is backwards incompatible Solution: revert patch v9.1.0965, detect bash scripts again as sh filetype This reverts commit b9b762c21f2b61e0e7d8fee43d4d3dc8ecffd721. related: vim/vim#16309 https://github.com/vim/vim/commit/727c567a0934643e2d6e1dd92d4e636b17d9067f Co-authored-by: Christian Brabandt <cb@256bit.org> vim-patch:9.1.1033: tests: shaderslang was removed from test_filetype erroneously Problem: tests: shaderslang was removed from test_filetype erroneously (Christian Clason, after v9.1.1030) Solution: restore the test https://github.com/vim/vim/commit/1d2867df0c5dfa3d2444229f9e4b23d6ff935956 Co-authored-by: Christian Brabandt <cb@256bit.org>
* fix(lua): prevent SIGSEGV when lua error is NULL in libuv_worker林玮 (Jade Lin)2025-01-18
| | | | | | | | | | | | | Problem: Calling `xstrdup` with a NULL pointer causes a SIGSEGV if `lua_tostring` returns NULL in `nlua_luv_thread_common_cfpcall`. Crash stack trace: - `_platform_strlen` → `xstrdup` (memory.c:469) - `nlua_luv_thread_common_cfpcall` (executor.c:281) Solution: Check if `lua_tostring` returns NULL and pass NULL to `event_create` to avoid the crash.
* fix(diagnostic)!: make virtual text handler opt-in (#32079)Gregory Anders2025-01-18
| | | | | | | | | | | Making this opt-out (on by default) was the wrong choice from the beginning. It is too visually noisy to be enabled by default. BREAKING CHANGE: Users must opt-in to the diagnostic virtual text handler by adding vim.diagnostic.config({ virtual_text = true }) to their config.
* fix(cmdline): prevent cmdline_show events after exiting cmdline #32033luukvbaal2025-01-15
| | | | | | Problem: If a (vim.ui_attach) cmdline_hide callback triggers a redraw, it may cause cmdline_show events for an already exited cmdline. Solution: Avoid emitting cmdline_show event when ccline.cmdbuff is already NULL. Unset ccline.cmdbuff before emitting cmdline_hide.
* Merge #32001 from MariaSolOs/consistent-namespacesJustin M. Keyes2025-01-15
|\
| * refactor: use nvim.foo.bar format for namespacesMaria José Solano2025-01-14
| |
* | feat(vim.fs): find(), dir() can "follow" symlinks #31551Mike2025-01-14
|/ | | | | | | | Problem: vim.fs.dir(), vim.fs.find() do not follow symlinks. Solution: - Add "follow" flag. - Enable it by default.
* feat: add vim.fs.relpathdundargoc2025-01-13
| | | | | This is needed to replace the nvim-lspconfig function is_descendant that some lspconfg configurations still use.
* docs: misc #31867Justin M. Keyes2025-01-09
|