Skip to content

How to remove virtual text (or trigger events.leave) when exiting insert mode #480

Answered by L3MON4D3
cydmium asked this question in Q&A
Discussion options

You must be logged in to vote

Using node:leave() should do it, but it might have side-effects (for example, if the content of the left node should be modified on leave)
Here's something that works, but consider it "unsupported" (I'll include something like it as ls.hide/show_extmarks in some time, I'm not sure yet if a simple hide/show_extmarks really is what we want here (as opposed to some abstraction one could do more with))

vim.api.nvim_create_autocmd("InsertLeave", {
	callback = function()
		local active_node = ls.session.current_nodes[1]
		if not active_node then
			return
		end
		local snippet = active_node.parent.snippet
		snippet:set_ext_opts("snippet_passive")
		snippet.mark:update_opts(snippet.ext_opts.snip…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@cydmium
Comment options

@L3MON4D3
Comment options

@cydmium
Comment options

@L3MON4D3
Comment options

Answer selected by cydmium
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants