Skip to content

Nesting snippets breaks ChoiceNodes #1334

@anthony-S93

Description

@anthony-S93

The desmonstration below uses the following snippets:

s(
        {
            trig = "eq"
        },
        {
            c(1, {
                sn(nil, {
                    t({"\\begin{equation}", "\t"}),
                    r(1, "body"),
                    t({"", "\\end{equation}"})
                }),
                sn(nil, {
                    t({"\\begin{equation*}", "\t"}),
                    r(1, "body"),
                    t({"", "\\end{equation*}"})
                })
            })
        },
        {
            stored = {
                ["body"] = i(1, "body")
            }
        }
    ),

    s(
        {
            trig = "test"
        },
        {
            t("test node")
        }
    ),

When tested, the snippets exhibited the following behavior:

2025-04-30-20-28-39.mp4

After another snippet is passed into an insertNode that is residing within a choiceNode, switching choices using luasnip-next-choice will work only one time before failing.

Is this by design? Are the entries in a choiceNode not meant to contain other Luasnip snippets?

-- Luasnip configs

local luasnip = require("luasnip")

    -- Set default snippet location
    require("luasnip.loaders.from_lua").lazy_load({
        paths = "~/.config/nvim/snippets"
    })

    -- Configurations
    luasnip.config.set_config({
        keep_roots = true,
        link_roots = true,
        link_children = true,
        exit_roots = false,
        enable_autosnippets = true,
        delete_check_events = "TextChanged,InsertEnter",
        updateevents = "TextChanged,TextChangedI",
        region_check_events = "CursorMoved"
    })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions