-
-
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
Better way to cancel the "session". #872
Comments
I think your desired behaviour should be |
Okay, |
It looks same with the problem, only useful when cursor skip the whole snippet region. |
If the feature can be achieve, coding must be more fluent. :) |
In Ultisnips we can use Could we have a kind of 'exit node' like this that cancels the current snippet when reached from a jump? |
Mhmm, yeah that could be implemented with a separate option.. should be worth it if ultisnips behaves like that (and they terminate snippets when the overall region is left, right?) Regarding the original request, disabling the snippet if the cursor is outside all of the placeholders (that's it, right?), should also be possible, maybe with the same option. |
If I remember correctly no, the snippet is exited when reaching snippet fn "desc" b
function $1(${2:args})
$0 -- exits on first jump to this placeholder, we can't use ultisnip jump mappings anymore
end
endsnippet Seems to be handled here: |
Ah, mh... Maybe the underlying issue: one thing that is possible now is always activating the node the cursor is at right now (via |
@L3MON4D3 so would you suggest using Sorry for the silly questions, I'm going over the "Snippet Insertion" docs and I'm just trying to wrap my head around the new settings 😅 |
Naaah, that autocommand should also work fine. With it, you'll deactivate the snippet as soon as InsertLeave happens, with actvate_node you'll always enter the node your cursor is on, which prevents this rather specific issue because the node the cursor is in is always the node that is "logically" active for luasnip, which has tge effect that jumps will generally not move back in the buffer, except if that is actually desired in the snippet. |
@L3MON4D3 that does help! My snippets aren't very complex, so I'm not looking for powerful snippet navigation. What I've just been struggling with is unlinking the snippet once my cursor has left the jumpable nodes, even if some of them remain unvisited. |
Nice :)
all of which is already implemented (at least in some form, maybe not a very nice api yet :D ), and would only need some official documentation |
I have read #258 and #770. Create a
autocmd
or setregion_check_events
to cancel the "session" is great. But if I create a big snippet, I thinkregion_check_events
cannot solve the "cancel" problem.For example, I use
html5~
snippet to create a basic html structure, so I will always code in the<body></body>
(in the snippet area). I move the cursor in<body></body>
then pressTab
. the cursor still jump to<title></title>
(the placeholder position). It's still annoyed.Is there any way to make luasnip cancel the "session" by detecting if cursor move out of the placeholder region (not just snippet region) ?
Like vscode ("edit,change the mode,move the cursor" will not cancel the session , but move cursor out of the placeholder region will do.)
The text was updated successfully, but these errors were encountered: