Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add jump node to the end of each snippet #1301

Open
aShabat opened this issue Feb 17, 2025 · 0 comments
Open

How to add jump node to the end of each snippet #1301

aShabat opened this issue Feb 17, 2025 · 0 comments

Comments

@aShabat
Copy link

aShabat commented Feb 17, 2025

Hello. I'm trying to add ability to jump to the end of each snippet. I can add this to my snippets, but I want to also be able to do this with lsp snippets. I wrote autocmd

vim.api.nvim_create_autocmd("User", {
    pattern = "LuasnipPreExpand",
    --once = true,
    callback = function()
        local snippet = require("luasnip").session.event_node
        local docstring = snippet:get_docstring()
        if not docstring[#docstring]:match('%$0$') then
            local luasnip = require'luasnip'
            local s = luasnip.s
            local i = luasnip.i
            local t = luasnip.t
            luasnip.snip_expand(
                s('surrounding snippet', {t("", ""), i(0)})
            )
        end
    end
})

but it adds empty snippet after the one that triggered the event. This works if i have link_roots = true in config, but i would prefer to disable it. Also this doesn't work without the text node, but I assume that it's because it becomes nothing-snippet.

Is there some other way to achieve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant