LuaSnip icon indicating copy to clipboard operation
LuaSnip copied to clipboard

get rid of "open" nodes

Open max397574 opened this issue 2 years ago • 7 comments

sometimes I don't jump through all the placeholders and there are still "unfinished" or "open" nodes or however you want to call them I got virtual text for nodes enabled and there is still some stuff ツ (tell me if it's even with those great explanations 😂 not clear what I mean) anyway this can sometimes lead to things like text getting inserted at random locations I wonder if there already is an api to be able to just get rid of all of those nodes. if not it would be really useful if this would be added.

max397574 avatar May 25 '23 15:05 max397574

Know what you mean :sweat_smile: You can work with region_check_events to jump out of those nodes on certain autocommand-events.

L3MON4D3 avatar May 25 '23 15:05 L3MON4D3

yes i know that but it would be useful to just get rid of them wherever you are without events

max397574 avatar May 25 '23 15:05 max397574

ig I could just do some hacky stuff myself with those functions

require("luasnip").exit_out_of_region(
	require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
)

but I'd prefer using a native solution

max397574 avatar May 25 '23 15:05 max397574

I guess the proper behaviour would be to completely leave the currently active snippet if the newly expanded snippet is not inside it, right? I'm about to improve the insertion-behaviour of snippets (base it on location in the buffer, not the currently active node while expanding the snippet), I'll definitely keep in mind to tack that on. Until then, feel free to do something hacky, I don't think there will be many changes until I implement that :wink:

L3MON4D3 avatar May 25 '23 17:05 L3MON4D3

I will rephrase the main problem as I am not 100% sure if my issue is the same (though I think so).

When I perform snippet expansion sometimes I don't jump over every placeholder and move on with the coding flow.

Then, whenever I use Tab I will be teleported back to "unfinished" placeholder locations which breaks the coding flow.

@max397574 How did you make the virtual text to show you the "open nodes"?

ghostbuster91 avatar Jun 07 '23 05:06 ghostbuster91

yes that's the same issue read the wiki for the virtual text

max397574 avatar Jun 07 '23 06:06 max397574

Okay, I think d9cb6ab should go a long way in improving behaviour here, lmk if there are still issues

L3MON4D3 avatar Oct 04 '23 13:10 L3MON4D3