Skip to content

Cannot make insert node 0 "inside" the snippet content #1275

Answered by fidelski
fidelski asked this question in Q&A
Discussion options

You must be logged in to vote

I obviously overlooked the following statement in the docs about node references:

number: the jump-index of the node. This will be resolved relative to the parent of the node this is passed to. (So, only nodes with the same parent can be referenced. This is very easy to grasp, but also limiting)

And since the dynamic node is not the root it cannot access its index. The following works as expected:

local function guard_name_node () return sn (nil, {i (1, get_guard_name ())}) end

return {
    s ({trig = 'incguard', desc = 'Insert include guard'}, fmt ([[
    #ifndef {}
    #define {}
    {}

    #endif // NOT {}

]], {d (1, guard_name_node), rep (1), i (0), rep (1)}))
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fidelski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant