Skip to content

Trigger Luasnips with hotkeys / programatically? #1235

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

You must be logged in to vote

Hi :)
snip_expand expects a snippet, it can't handle a raw string, even if it identifies a snippet somewhat uniquely, you need to do some more stuff manually. I think #389 shows this pretty good, for an illustrating example of what's going on there try

vim.keymap.set({ 'n' }, "<leader>r", function () require('luasnip').snip_expand(s({trig = "````", name = "Codeblock"}, fmt([[
    ````{}
    $TM_SELECTED_TEXT
    ````
    ]], {
      i(1)
  }))) end)

with the required globals defined

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Oneechan69
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