Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
7255290
implement optional argnodes.
L3MON4D3 Dec 28, 2023
7ca8fab
implement subtree_do, invokes callbacks on tree of nodes (in a snippet).
L3MON4D3 Mar 4, 2024
6787860
make resolve_position work for static snippets.
L3MON4D3 Mar 4, 2024
7280e30
fix: make root_path work for snippets.
L3MON4D3 Mar 4, 2024
93b78bd
implement subtree_leave_entered, for leaving only entered nodes.
L3MON4D3 May 5, 2025
ef72739
overhaul snippet-updates.
L3MON4D3 Mar 4, 2024
3be4f96
make sure visible is set on -1-node.
L3MON4D3 Mar 10, 2024
5cfa644
propery remove child-snippets when `:exit`ing.
L3MON4D3 Apr 23, 2024
5d175a8
exitNode: use same update_dependents as all other nodes.
L3MON4D3 Apr 23, 2024
57be439
update after snip_expand.
L3MON4D3 Oct 14, 2025
28ee8de
Format with stylua
L3MON4D3 Oct 14, 2025
a32304d
Make insertNode correctly handle static_text if it's a snippetString.
L3MON4D3 Oct 28, 2024
a02b350
allow using snippet_string as dynamicNode-args.
L3MON4D3 Oct 28, 2024
1539abc
restoreNode,insertNode: propagate store.
L3MON4D3 Oct 29, 2024
4917cde
dynamicNode.update: store snippet before evaluating fn.
L3MON4D3 Oct 29, 2024
7978f18
dynamicNode.update: copy extmarks after focusing.
L3MON4D3 Oct 29, 2024
afcf2a7
dynamicNode.update: do update_restore instead of update.
L3MON4D3 Oct 29, 2024
0488636
restoreNode: don't store on exit, store should have been called before.
L3MON4D3 Oct 29, 2024
0b68948
add some tests for new restoreNode-behaviour.
L3MON4D3 Oct 29, 2024
6ac4c97
choiceNode: correctly refocus when current_node is in another snippet.
L3MON4D3 Oct 29, 2024
7e84074
we don't want to go into adjacent snippetNodes, but land between them.
L3MON4D3 Oct 29, 2024
02dc83d
snippet: correctly propagate exit to child_snippets (and clear them).
L3MON4D3 Oct 29, 2024
ef040dc
add another test for the new restoreNode.
L3MON4D3 Oct 29, 2024
d4ddbb4
store content of nested snippets before capturing argnode.
L3MON4D3 Oct 29, 2024
924d7dd
make sure marks are invalidated even for nested snippets.
L3MON4D3 Oct 29, 2024
9d2399b
get_args: `store` only when calling in static mode.
L3MON4D3 Oct 29, 2024
0ded7ac
snippetstring: store strings as \n-separated string.
L3MON4D3 Oct 14, 2025
b477c07
small refactor.
L3MON4D3 Oct 30, 2024
e7d6627
implement a few simple string-operations on snippetString.
L3MON4D3 Oct 30, 2024
49c72ae
fix flakiness in test.
L3MON4D3 Oct 30, 2024
3dc03f8
update: try to find new active node in child-snippet.
L3MON4D3 Oct 30, 2024
4091612
allow replacing parts of a snippetString with other text.
L3MON4D3 Nov 2, 2024
aedf564
implement gsub on snippetString.
L3MON4D3 Nov 2, 2024
3b2414d
snippetstring.replace: fix substitution in textNode.
L3MON4D3 Nov 2, 2024
2537da0
fix switchup.
L3MON4D3 Nov 2, 2024
4a0103e
make in-place modifying functions private.
L3MON4D3 Nov 2, 2024
96f1e64
add :sub to snippetString.
L3MON4D3 Nov 2, 2024
68b2f39
add `opt` for the optional argument.
L3MON4D3 Nov 3, 2024
a21ef50
correctly store+restore visual selection during update.
L3MON4D3 Nov 3, 2024
31ad740
fNode: always store result in static_text.
L3MON4D3 Nov 4, 2024
8a6f1a9
update_dependents: get cursor-position after queried movements.
L3MON4D3 Nov 4, 2024
41e03ed
move the jump_active-check into the autocommand.
L3MON4D3 Oct 14, 2025
4af87a1
optionally update a node differnt from the current node.
L3MON4D3 Oct 14, 2025
05e8dc0
update_dependents: use update_restore by default.
L3MON4D3 Nov 4, 2024
bae30cb
choiceNode: call update_dependents after routine is done completely.
L3MON4D3 Nov 4, 2024
f360595
move no_region_wrap back into main-module.
L3MON4D3 Oct 14, 2025
5e0bd64
dynamicNode/restoreNode: don't destroy snip on exit.
L3MON4D3 Nov 4, 2024
be11293
handle selection on first line and column of buffer with `before`.
L3MON4D3 Nov 4, 2024
f71ed75
document imperfect behaviour asserted by test.
L3MON4D3 Nov 4, 2024
301c600
export optional_arg as opt for tests.
L3MON4D3 Nov 4, 2024
71163f0
set jump_active=false ASAP.
L3MON4D3 Nov 4, 2024
5f307cc
choiceNode: explicitly set parent and pos for choices.
L3MON4D3 Nov 6, 2024
bdfdb8e
fix(dynamicNode): don't access .snip in update_static.
L3MON4D3 Nov 6, 2024
1707e93
dynamicNode: optionally use .snip to generate docstring.
L3MON4D3 Nov 6, 2024
8c91720
enqueue cursor-movement due to update in typeahead.
L3MON4D3 Nov 6, 2024
3439a5b
get_args: do (static_)visible-check in get_args, not get_static_text.
L3MON4D3 Nov 6, 2024
87637ea
test docstring-generation with self-dependent dynamicNode.
L3MON4D3 Nov 6, 2024
b2dbd41
properly restore cursor-position in set_choice.
L3MON4D3 Nov 7, 2024
cbca762
change_choice: use cursor-restore system from update_dependents.
L3MON4D3 Oct 14, 2025
e088a0e
snippet_string: add metadata and marks.
L3MON4D3 Nov 13, 2024
0fbe832
store cursor-position in snippetString to more accurately restore it.
L3MON4D3 Oct 14, 2025
e1cdc64
api_enter: only log an error when called recursively.
L3MON4D3 Nov 14, 2024
3a45291
feedkeys: ignore errors on asynchronous nvim_win_set_cursor.
L3MON4D3 Nov 14, 2024
decab9e
correctly restore self-dependent dynamicNode.
L3MON4D3 Nov 14, 2024
3501f75
change/set/select_choice: update current node before modifying choice.
L3MON4D3 Oct 14, 2025
cb16ac0
add a few tests for previous changes.
L3MON4D3 Nov 14, 2024
e1c276c
Format with stylua
L3MON4D3 Oct 14, 2025
f047e41
fix: pass correct arguments to str_byteindex.
L3MON4D3 May 5, 2025
8e92df9
fix: handle unicode->snippetstring->unicode conversion correctly.
L3MON4D3 May 5, 2025
3e273b3
add a few annotations.
L3MON4D3 Oct 14, 2025
829bcfa
feedkeys: only clear action after its confirm is called.
L3MON4D3 May 16, 2025
d37628e
store: check that child-snip has valid extmarks before storing.
L3MON4D3 Jun 3, 2025
1d48d2f
improve logging of dynamicNode.
L3MON4D3 Oct 19, 2025
f041238
dynamicNode: limit number of nested updates.
L3MON4D3 Oct 19, 2025
7fe81a9
rip out update_depth again.
L3MON4D3 Oct 19, 2025
ffd2e53
Auto generate docs
L3MON4D3 Oct 19, 2025
8eddf68
Format with stylua
L3MON4D3 Oct 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/luasnip.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*luasnip.txt* For NeoVim 0.7-0.11 Last change: 2025 October 17
*luasnip.txt* For NeoVim 0.7-0.11 Last change: 2025 October 19

==============================================================================
Table of Contents *luasnip-table-of-contents*
Expand Down
3 changes: 1 addition & 2 deletions lua/luasnip/_types.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---@alias LuaSnip.Cursor {[1]: number, [2]: number}

--- 0-based region within a single line
---@class LuaSnip.MatchRegion
---@class LuaSnip.MatchRegion 0-based region within a single line
---@field row integer 0-based row
---@field col_range { [1]: integer, [2]: integer } 0-based column range, from-in, to-exclusive

Expand Down
12 changes: 8 additions & 4 deletions lua/luasnip/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ c = {
require("luasnip").unlink_current_if_deleted
)
end
ls_autocmd(
session.config.update_events,
require("luasnip").active_update_dependents
)
ls_autocmd(session.config.update_events, function()
-- don't update due to events if an update due to luasnip is pending anyway.
-- (Also, this would be bad because luasnip may not be in an
-- consistent state whenever an autocommand is triggered)
if not session.jump_active then
require("luasnip").active_update_dependents()
end
end)
if session.config.region_check_events ~= nil then
ls_autocmd(session.config.region_check_events, function()
require("luasnip").exit_out_of_region(
Expand Down
3 changes: 3 additions & 0 deletions lua/luasnip/default_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ local lazy_snip_env = {
k = function()
return require("luasnip.nodes.key_indexer").new_key
end,
opt = function()
return require("luasnip.nodes.optional_arg").new_opt
end,
ai = function()
return require("luasnip.nodes.absolute_indexer")
end,
Expand Down
47 changes: 37 additions & 10 deletions lua/luasnip/extras/select_choice.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,52 @@
local session = require("luasnip.session")
local ls = require("luasnip")
local node_util = require("luasnip.nodes.util")
local feedkeys = require("luasnip.util.feedkeys")

local function set_choice_callback(_, indx)
if not indx then
return
-- in this procedure, make sure that api_leave is called before
-- set_choice_callback exits.
local function set_choice_callback(data)
return function(_, indx)
if not indx then
ls._api_leave()
return
end
-- set_choice restores cursor from before.
ls._set_choice(indx, { cursor_restore_data = data, skip_update = true })
ls._api_leave()
end
-- feed+immediately execute i to enter INSERT after vim.ui.input closes.
vim.api.nvim_feedkeys("i", "x", false)
ls.set_choice(indx)
end

local function select_choice()
assert(
session.active_choice_nodes[vim.api.nvim_get_current_buf()],
"No active choiceNode"
)
vim.ui.select(
ls.get_current_choices(),
{ kind = "luasnip" },
set_choice_callback
local active = session.current_nodes[vim.api.nvim_get_current_buf()]

ls._api_enter()

ls._active_update_dependents()

if not session.active_choice_nodes[vim.api.nvim_get_current_buf()] then
print("Active choice was removed while updating a dynamicNode.")
return
end

local restore_data = node_util.store_cursor_node_relative(
active,
{ place_cursor_mark = true }
)

-- make sure all movements are done, otherwise the movements may be put into
-- the select-dialog.
feedkeys.enqueue_action(function()
vim.ui.select(
ls.get_current_choices(),
{ kind = "luasnip" },
set_choice_callback(restore_data)
)
end)
end

return select_choice
Loading