I have this in my init.lua
, I looked up how to trigger it programmatically including these discussion posts and the documentation, but couldn’t figure it out. This is my Luasnip config
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local fmt = require("luasnip.extras.fmt").fmt
ls.add_snippets("all", {
s({trig = "````", name = "Codeblock"}, fmt([[
````{}
$TM_SELECTED_TEXT
````
]], {
i(1)
})),
s({trig = "sspan", name = "Custom Span"}, fmt("<span style=\"{}\">{}</span>", {
i(1), i(2)
})),
})
I tried this but it doesn’t seem to work: vim.keymap.set({ 'n' }, "<leader>r", function () require('luasnip').snip_expand("Codeblock") end)
. I get this error (home folder name omitted):
E5108: Error executing lua: .../.local/share/nvim/lazy/LuaSnip/lua/luasnip/init.lua:230: attempt to call method 'copy' (a nil
value)
stack traceback:
.../.local/share/nvim/lazy/LuaSnip/lua/luasnip/init.lua:230: in function 'snip_expand'
/Users/../.config/nvim/init.lua:318: in function </Users/.../.config/nvim/init.lua:318>