-
-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow self-dependent dynamicNode #1137
base: master
Are you sure you want to change the base?
Commits on Nov 6, 2024
-
In that case, there will be a `nil` at the place of the text of the node in the arg-list. They have to be explicitly marked as optional, since we currently have the behaviour of not updating nodes at all if an argnode is missing.
Configuration menu - View commit details
-
Copy full SHA for 3342a54 - Browse repository at this point
Copy the full SHA 3342a54View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8f82c73 - Browse repository at this point
Copy the full SHA 8f82c73View commit details -
make resolve_position work for static snippets.
dynamicNode has to return .static_snip instead of .snip
Configuration menu - View commit details
-
Copy full SHA for c61d083 - Browse repository at this point
Copy the full SHA c61d083View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3f56b38 - Browse repository at this point
Copy the full SHA 3f56b38View commit details -
Configuration menu - View commit details
-
Copy full SHA for de8dd21 - Browse repository at this point
Copy the full SHA de8dd21View commit details -
Previously: InsertNodes trigger an update on input_leave. This works, but, if updates invalidate nodes that are currently involved in being jumped over, we'd have to abort and roll back the jump, or do some other recovery. To avoid this, update_dependents is done _before_ any jumping is performed (this is really more elegant now since we can keep track of which nodes are "above" some insertNode, and then just get all of them and their dependents (see node_util.find_node_dependents/collect_dependents)) So, now `ls.jump` does essentially: * store position of cursor relative to active node * collect nodes that depend on the text of this node (so, all dependents of all parents of this node) * update them * try to find an equivalent node (node with the same key, or if a restoreNode is present, the exact same node :D) and perform the jump from it * if an equivalent node could not be found, just enter the first dynamicNode (starting from the previously active node) and enter it Obviously, this only really works well if an equivalent of the current node can be found in the new generated nodes. Similarly, active_update_dependents
Configuration menu - View commit details
-
Copy full SHA for 20b61a2 - Browse repository at this point
Copy the full SHA 20b61a2View commit details -
Configuration menu - View commit details
-
Copy full SHA for db12345 - Browse repository at this point
Copy the full SHA db12345View commit details -
make sure visible is set on -1-node.
put_initial is not called on it, but since it's always visible we can set it when initializing.
Configuration menu - View commit details
-
Copy full SHA for e80c049 - Browse repository at this point
Copy the full SHA e80c049View commit details -
propery remove child-snippets when
:exit
ing.This is important to prevent an infinite loop when a snippet is remove_from_jumplist'd in node_util.snippettree_find_undamaged_node: if child_snippets is not modified, we just continue to remove it (or call :r_f_j but immediately nop because the snippet is not visible).
Configuration menu - View commit details
-
Copy full SHA for da3529b - Browse repository at this point
Copy the full SHA da3529bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9b5450f - Browse repository at this point
Copy the full SHA 9b5450fView commit details -
Has to happen because we modified text. I don't like using vim.schedule here, but it seems like this is the only way of getting the desired behaviour into all possible ways of expanding snippets (direct snip_expand is used by cmp_luasnip, so can't just handle `expand` and its variants in init.lua (or, we could do so and submit a PR to cmp_luasnip, but let's wait with that until this actually becomes problematic, which I don't think it will)).
Configuration menu - View commit details
-
Copy full SHA for 3c0d125 - Browse repository at this point
Copy the full SHA 3c0d125View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7e26ca5 - Browse repository at this point
Copy the full SHA 7e26ca5View commit details -
Make insertNode correctly handle static_text if it's a snippetString.
This includes `put_initial`, so a restoreNode will now store snippets expanded inside of it!! (which is really cool :D)
Configuration menu - View commit details
-
Copy full SHA for ab84254 - Browse repository at this point
Copy the full SHA ab84254View commit details -
allow using snippet_string as dynamicNode-args.
This allows us to duplicate snippets within argnodes into the dynamicNode.
Configuration menu - View commit details
-
Copy full SHA for d08cf30 - Browse repository at this point
Copy the full SHA d08cf30View commit details -
restoreNode,insertNode: propagate store.
If store is triggered manually (for example in dynamicNode:update), it should also be performed for the entire snippetTree!
Configuration menu - View commit details
-
Copy full SHA for f8b7d1a - Browse repository at this point
Copy the full SHA f8b7d1aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3a7c677 - Browse repository at this point
Copy the full SHA 3a7c677View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8bd88b2 - Browse repository at this point
Copy the full SHA 8bd88b2View commit details -
dynamicNode.update: do update_restore instead of update.
This enables restoring the dynamicNode content in snippetStrings.
Configuration menu - View commit details
-
Copy full SHA for 8c0bb59 - Browse repository at this point
Copy the full SHA 8c0bb59View commit details -
restoreNode: don't store on exit, store should have been called before.
exit is also called when a snippet should be deleted due to invalid extmarks, if we do something like store in there, we have to always check extmarks. For now, leave a pcall in get_snippetstring, get_text behaved the same. But log errors!
Configuration menu - View commit details
-
Copy full SHA for 6f39702 - Browse repository at this point
Copy the full SHA 6f39702View commit details -
Configuration menu - View commit details
-
Copy full SHA for fc94ef2 - Browse repository at this point
Copy the full SHA fc94ef2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 65b9e7e - Browse repository at this point
Copy the full SHA 65b9e7eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4f52fd2 - Browse repository at this point
Copy the full SHA 4f52fd2View commit details -
Configuration menu - View commit details
-
Copy full SHA for afa887c - Browse repository at this point
Copy the full SHA afa887cView commit details -
Configuration menu - View commit details
-
Copy full SHA for a78be52 - Browse repository at this point
Copy the full SHA a78be52View commit details -
Configuration menu - View commit details
-
Copy full SHA for eb9cefd - Browse repository at this point
Copy the full SHA eb9cefdView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1688ba3 - Browse repository at this point
Copy the full SHA 1688ba3View commit details -
get_args:
store
only when calling in static mode.weirdly that one test breaks, and only on nvim0.7.. I don't think it's an actual bug in luasnip. so just skipping that test for now.
Configuration menu - View commit details
-
Copy full SHA for 6fa5d02 - Browse repository at this point
Copy the full SHA 6fa5d02View commit details -
snippetstring: store strings as \n-separated string.
This should simplify applying string-operations. Also don't store the string of a snippet, just reconstruct it when needed. We do this because it is much easier than figuring out exactly how indent or expand affect a snippet (indentSnippetNode can affect them, so keeping them in sync manually seems infeasible.)
Configuration menu - View commit details
-
Copy full SHA for 41b8811 - Browse repository at this point
Copy the full SHA 41b8811View commit details -
set parent_node in insert_into_jumplist, and rename reown to copy (so it can be used more generally and not just in the context of some insertNode receiving the snippetString as static_text).
Configuration menu - View commit details
-
Copy full SHA for 81a1c9d - Browse repository at this point
Copy the full SHA 81a1c9dView commit details -
implement a few simple string-operations on snippetString.
lower, upper, and ..
Configuration menu - View commit details
-
Copy full SHA for 9d0dfd6 - Browse repository at this point
Copy the full SHA 9d0dfd6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4f50d6c - Browse repository at this point
Copy the full SHA 4f50d6cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 78419f1 - Browse repository at this point
Copy the full SHA 78419f1View commit details -
allow replacing parts of a snippetString with other text.
If possible, snippets are preserved, and if they can't be preserved they will gracefully degrade to raw text.
Configuration menu - View commit details
-
Copy full SHA for 0213852 - Browse repository at this point
Copy the full SHA 0213852View commit details -
Configuration menu - View commit details
-
Copy full SHA for 83a2793 - Browse repository at this point
Copy the full SHA 83a2793View commit details -
Configuration menu - View commit details
-
Copy full SHA for b14f25f - Browse repository at this point
Copy the full SHA b14f25fView commit details -
Configuration menu - View commit details
-
Copy full SHA for bd58f4d - Browse repository at this point
Copy the full SHA bd58f4dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 56b9e1a - Browse repository at this point
Copy the full SHA 56b9e1aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 483656e - Browse repository at this point
Copy the full SHA 483656eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1d8aa65 - Browse repository at this point
Copy the full SHA 1d8aa65View commit details -
Configuration menu - View commit details
-
Copy full SHA for de53515 - Browse repository at this point
Copy the full SHA de53515View commit details -
fNode: always store result in static_text.
:store only really makes sense for nodes where we can't store the text as its' being generated, which is exclusively insertNode.
Configuration menu - View commit details
-
Copy full SHA for 31f9740 - Browse repository at this point
Copy the full SHA 31f9740View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4244a88 - Browse repository at this point
Copy the full SHA 4244a88View commit details -
move the jump_active-check into the autocommand.
Whenever update_dependents is called by luasnip, we can be sure that it's safe to call currently.
Configuration menu - View commit details
-
Copy full SHA for dfe82fb - Browse repository at this point
Copy the full SHA dfe82fbView commit details -
Configuration menu - View commit details
-
Copy full SHA for be863e7 - Browse repository at this point
Copy the full SHA be863e7View commit details -
update_dependents: use update_restore by default.
if we can restore a previously generated snippet, we should do so to not revert user input.
Configuration menu - View commit details
-
Copy full SHA for 2cb3fa1 - Browse repository at this point
Copy the full SHA 2cb3fa1View commit details -
choiceNode: call update_dependents after routine is done completely.
safer, update_dependents could remove the entire choiceNode, not good!
Configuration menu - View commit details
-
Copy full SHA for 9020719 - Browse repository at this point
Copy the full SHA 9020719View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1ee7430 - Browse repository at this point
Copy the full SHA 1ee7430View commit details -
dynamicNode/restoreNode: don't destroy snip on exit.
And store generated snippet in .snip, not .snip_stored, which is not reached by subtree_do, which we would like to have apply to the stored snippet.
Configuration menu - View commit details
-
Copy full SHA for 155331f - Browse repository at this point
Copy the full SHA 155331fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9c70626 - Browse repository at this point
Copy the full SHA 9c70626View commit details -
Configuration menu - View commit details
-
Copy full SHA for bab5962 - Browse repository at this point
Copy the full SHA bab5962View commit details -
Configuration menu - View commit details
-
Copy full SHA for 90c2fc6 - Browse repository at this point
Copy the full SHA 90c2fc6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 79b985e - Browse repository at this point
Copy the full SHA 79b985eView commit details -
choiceNode: explicitly set parent and pos for choices.
Previously, we used a metatable to refer to the choiceNode for some keys that are required, which are only .parent and .pos.
Configuration menu - View commit details
-
Copy full SHA for 583befe - Browse repository at this point
Copy the full SHA 583befeView commit details -
Configuration menu - View commit details
-
Copy full SHA for feeac25 - Browse repository at this point
Copy the full SHA feeac25View commit details -
dynamicNode: optionally use .snip to generate docstring.
This may improve the accuracy of docstrings generated on an expanded snippet.
Configuration menu - View commit details
-
Copy full SHA for 733ccb2 - Browse repository at this point
Copy the full SHA 733ccb2View commit details -
enqueue cursor-movement due to update in typeahead.
Otherwise the jump_into from change_choice may complete after the cursor-movement due to the subsequent update.
Configuration menu - View commit details
-
Copy full SHA for 211254b - Browse repository at this point
Copy the full SHA 211254bView commit details -
get_args: do (static_)visible-check in get_args, not get_static_text.
Much more appropriate, also get_current_choices will work even if some insertNode is not visible.
Configuration menu - View commit details
-
Copy full SHA for ae8d95c - Browse repository at this point
Copy the full SHA ae8d95cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3d8f8bd - Browse repository at this point
Copy the full SHA 3d8f8bdView commit details
Commits on Nov 7, 2024
-
properly restore cursor-position in set_choice.
* handle column-shifted begin-position (only shift cursor-column if it stays in the same line) * correctly enqueue cursor-movement via feedkeys.
Configuration menu - View commit details
-
Copy full SHA for 14280e1 - Browse repository at this point
Copy the full SHA 14280e1View commit details -
change_choice: use cursor-restore system from update_dependents.
Code is essentially the same thing. Also allow passing the current cursor to ls.set/change_choice, which is useful for extras.select_choice, where the cursor-state is "destroyed" due to vim.input, and should be saved before that is even opened.
Configuration menu - View commit details
-
Copy full SHA for 1464b3f - Browse repository at this point
Copy the full SHA 1464b3fView commit details
Commits on Nov 13, 2024
-
snippet_string: add metadata and marks.
metadata can store eg. when a snippetString was created, marks are a bit like extmarks, they can mark a position in a snippetString and are shifted by text-insertions.
Configuration menu - View commit details
-
Copy full SHA for f78bf74 - Browse repository at this point
Copy the full SHA f78bf74View commit details
Commits on Nov 14, 2024
-
store cursor-position in snippetString to more accurately restore it.
Cache `static_text` (for insertNodes) and don't query it anew while luasnip is operating. This is valid under the assumption that all changes to the buffer are due to luasnip while an api-function (jump, expand, etc.) is running. This is enabled by session.luasnip_changedtick which is set as soon as an api-function is called, and prevents re-fetching snippetStrings from the buffer (which in turn allows us to set the cursor-position once, and then have it propagate through all updates that are triggered subsequently). This commit also replaces no_region_check_wrap with api_do, which is more general (handles both jump_active, which prevents recursive api-calls and luasnip_changedtick)
Configuration menu - View commit details
-
Copy full SHA for d553a79 - Browse repository at this point
Copy the full SHA d553a79View commit details -
Configuration menu - View commit details
-
Copy full SHA for fe21f49 - Browse repository at this point
Copy the full SHA fe21f49View commit details -
feedkeys: ignore errors on asynchronous nvim_win_set_cursor.
See extensive comment in commit.
Configuration menu - View commit details
-
Copy full SHA for f19ebbd - Browse repository at this point
Copy the full SHA f19ebbdView commit details -
correctly restore self-dependent dynamicNode.
By inserting the stored snip into the buffer, `get_args` during `update_restore` can find the argnode inside the snippet.
Configuration menu - View commit details
-
Copy full SHA for f13c479 - Browse repository at this point
Copy the full SHA f13c479View commit details -
change/set/select_choice: update current node before modifying choice.
If we don't do this, the content of a choiceNode may not be restored correctly. (or, it will be restored correctly, but it won't be what the user saw before they called change/set/select_choice, which seems suboptimal).
Configuration menu - View commit details
-
Copy full SHA for a76f573 - Browse repository at this point
Copy the full SHA a76f573View commit details -
Configuration menu - View commit details
-
Copy full SHA for d066147 - Browse repository at this point
Copy the full SHA d066147View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1aa841e - Browse repository at this point
Copy the full SHA 1aa841eView commit details -
Configuration menu - View commit details
-
Copy full SHA for cabdbfa - Browse repository at this point
Copy the full SHA cabdbfaView commit details