Skip to content
Discussion options

You must be logged in to vote

Mhmm, we don't really have a reliable api for the general case (for any cursor-position, find whether it is immediately behind some active snippet), but for this specific case where you've just jumped to the $0, you can get the trigger of the snippet before the cursor, and whether you've just jumped to the $0

local current_node = require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
local current_snippet_trigger = current_node.parent.snippet.trigger
local current_is_0 = current_node.pos == 0

(maybe, also check whether the cursor is actually still on the $0, get the position via current_node:get_buf_position(), and check it against the position of the cursor (beware of 0…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@boltlessengineer
Comment options

Answer selected by boltlessengineer
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