-
-
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
Deleting a snippet does not stop completion #116
Comments
Oops, seems like this is a duplicate of #75. I managed to get the behaviour I want with vim.api.nvim_set_keymap('i', '<esc>', '<c-o>:lua Luasnip_current_nodes[vim.api.nvim_get_current_buf()] = nil<cr><esc>', { noremap=true, silent=true }) This kind of feels like a hack though... |
Yeah, it is a bit hacky, it'll destroy any snippet-history you might want to actually keep. |
Okay, that setting is implemented now, you can set |
Great, thanks for the quick fix! I'll give it a try when I find some time to once again change my vim config :P Regarding the other possible method, I don't think that would work well for my use case, mostly because "eh, I messed up |
Yeah I completely get that, for now even with this you'll have to leave the line the snippet was on to leave it. |
I've given it some more thought and implemented a function that can be called on delete to check if the current snippet is deleted entirely and, if so, removes it from the jumplist. nmap dd dd<Plug>luasnip-delete-check to have it work, but maybe those maps will be added to luasnip so you won't have to set them up for all possible commands that delete text. I did some testing and it works pretty well for eg. |
I think setting
If this is unacceptable, setting Would running Personally, I would like to be able to have a snippet's jumps removed from the history when its region is left. Put another way, when |
Running the deleted check in an autocommand seems to work fine for me. Unless the delete check is heavier than it should be this seems fine. Here's what I used: augroup CustomLuaSnip
au!
au TextChanged,InsertLeave * lua require'luasnip'.unlink_current_if_deleted()
augroup end |
Oh yes, that's also pretty nice, I'll put it into the Readme as a recommendation.
No, not really, I did it this way because the specific example of
I get that, i didn't 'enable' |
Nice, I'll put that in as a setting👍 |
I absolutely agree that LuaSnip shouldn't do more than necessary with default settings. It's this sort of principle which is one reason I prefer (Neo)Vim over a monolithic IDE. It's hard to beat an IDE which starts in well under a second and is also ideal for editing any plain text file format in existence. LuaSnip should be just as light, and just as powerful, and there's nothing to say it can't be. Good to hear there'll be a setting for this. |
Whoops, forgot to comment here yesterday: 0db416c adds the setting. |
Sorry, but how should one go about setting
Should that be working? |
Put it in the table you pass to local ls = require('luasnip')
ls.config.set_config({
region_check_events = "CursorMoved",
})
The values for local ls = require('luasnip')
ls.config.set_config({
region_check_events = "InsertEnter",
delete_check_events = "TextChanged,InsertLeave",
}) |
I recently switched to this plugin from ultisnips and from what I've seen so far, it's really nice, however, one thing is bugging me.
I often start typing out a snippet, then change my mind, exit insert mode delete the snippet or line without going to the end of the snippet. Ultisnips would handle that gracefully, but it seems like luasnip continues expanding stuff even after that point, which I find very annoying.
Example of the behaviour, (using this snippet)
Peek.2021-08-16.14-21.mp4
Is there a way of avoiding this behavour? Ideally, something like "if the snippet was deleted, abort", but I'd also be fine with exiting insert mode cancelling the snippet creation no matter what
The text was updated successfully, but these errors were encountered: