aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/snippet_spec.lua
Commit message (Collapse)AuthorAge
* 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