aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/snippet_spec.lua
Commit message (Collapse)AuthorAge
* fix(snippet): preserve the full TM_DIRECTORY path (#42408)Volodymyr Chernetskyi3 days
| | | | | | | | | | Problem: TM_DIRECTORY expands to the directory's basename, losing its parent path. Solution: Remove the tail modifier when expanding the current file's directory. Extend the existing known-variable test to check the full directory path. AI-assisted
* fix(snippet): cancel session on ESC in insert-mode #41555Nathan Zeng2026-08-30
| | | | | | | | Problem: If a snippet does not have a placeholder, we use insert mode instead of select mode. From here <Esc> leaves the session and highlight active. Solution: Cancel the session on <Esc>.
* 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(snippet): cancel session on <Esc> in Select mode #39238glepnir2026-05-10
| | | | | | | Problem: <Esc> in a Select-mode tabstop leaves the session and highlight active. CursorMoved isn’t triggered since the cursor doesn’t move. Solution: use ModeChanged (s:n) instead. Defer with vim.schedule() to avoid transient s:n from jump().
* feat(snippet): support multiple sessions #29340Maria Solano2026-04-10
|
* test: don't call clear() in both before_each() and after_each() (#35901)zeertzjq2025-09-24
|
* feat(snippet): highlight active tabstop (#35378)TheBlob422025-08-19
|
* fix(snippet): adjacent tabstops without placeholders (#35167)TheBlob422025-08-13
| | | | | * fix(snippet): adjacent tabstops without placeholders * test(snippet): add tests for directly adjacent tabstops
* fix(snippet): early return for final tabstop #35115TheBlob422025-08-03
| | | | | The cursor movement autocommand can not detect when the final tabstop $0 is directly adjacent to another tabstop, which prevents ending the snippet session. The fix is an early return when jumping.
* fix(snippet): jumping backwards to choice node (#35062)TheBlob422025-07-27
| | | | Avoid duplicate text when jumping back to a choice node. Set cursor to end of tabstop range and prioritize current choice in completion items.
* fix(snippet): setting end_right_gravity (#35061)TheBlob422025-07-27
| | | | | | When right_gravity is set to true for deactivating tabstop expansion we have to set end_right_gravity to false to avoid expanding the tabstop region on the right side. Vice versa for activating tabstop expansion again.
* fix(snippet): use <cmd>call cursor() for visual rangeLuuk van Baal2025-04-23
| | | | | | | | Problem: Change applied in d3e495ce uses a byte-offset where a virtual column is expected. Solution: Set the cursor directly through a <Cmd> mapping, while making sure the commands are ordered correctly by adding them to the type-ahead buffer.
* 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.
* 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(snippet): modify base indentation when there's actually whitespace (#29670)Maria José Solano2024-07-16
|
* feat(snippet): add default keymaps during snippet sessionMaria José Solano2024-05-28
|
* fix(lsp): redundant vim.snippet.jumpable #28560Maria José Solano2024-04-29
|
* fix(snippet): do not add extra indent on newlines (#28538)Mathias Fußenegger2024-04-28
| | | | | | | | | | | | | | | | | | | | | | | Reverts parts of https://github.com/neovim/neovim/pull/27674 LSP snippets typically do include tabs or spaces to add extra indentation and don't rely on the client using `autoindent` functionality. For example: public static void main(String[] args) {\n\t${0}\n} Notice the `\t` after `{\n` Adding spaces or tabs independent of that breaks snippets for languages like Haskell where you can have snippets like: ${1:name} :: ${2}\n${1:name} ${3}= ${0:undefined} To generate: name :: name = undefined
* 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.
* fix(snippet): correct indent with newlineglepnir2024-03-01
| | | | | | Problem: snippet newline use before line indent after expand. Solution: it should level + 1.
* fix(lsp): add snippet regression test (#27618)Maria José Solano2024-02-25
|
* fix(lsp): handle adjacent snippet tabstopsMaria José Solano2024-02-05
|
* test(lua/snippet_spec): wait for completion menu (#27243)zeertzjq2024-01-28
| | | | This fixes the flakiness caused by typing a completion menu key when the completion menu hasn't showed up.
* test: remove helpers.sleep()Lewis Russell2024-01-12
|
* refactor: format test/*Justin M. Keyes2024-01-03
|
* refactor(snippet): rename test utilitiesMaria José Solano2023-11-17
|
* feat(lsp): support for choice snippet nodesMaria José Solano2023-11-17
|
* fix(lsp): do not cancel snippet when selecting placeholder (#25835)Maria José Solano2023-10-30
|
* fix(lsp): cancel session when leaving snippet region (#25762)Maria José Solano2023-10-26
|
* fix(lsp): do not add extra indentationMaria José Solano2023-10-23
|
* fix(lsp): track snippet deletionMaria José Solano2023-10-23
|
* feat(lsp): add snippet API (#25301)Maria José Solano2023-10-21