-
Hi, Is it possible to do the following ultisnips code in lua/luasnip? def dashes18(): snippet dc "Declare Cursor" b The cursor name can be a max of 18 characters long so it prints 18 dashes when initially invoked and reduces by 1 every time I type a character. I just use the dashes as I guide so I dont have to count the letters as I type. Any guidance would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi :) That's possible: s("dc", fmt([[
DECLARE {i1} {dashes18} CURSOR FOR
{i0}
FREE {i1}
]], {
i1 = i(1, "", {key = "first"}),
dashes18 = f(function(args)
return ("-"):rep(18 - #args[1][1])
end, k("first")),
i0 = i(0)
}, {repeat_duplicates = true})) You'll also have to set
if you want to see the dashes update as you type |
Beta Was this translation helpful? Give feedback.
-
Beautiful, that works a treat, thank you. Is there by anychance a way of removing any remaining dashes after leaving field 1? DECLARE small_curs ------- CURSOR FOR FREE small_curs I can move the dashes to the line below and remove when finished but just looking to increase my knowledge of luasnip. |
Beta Was this translation helpful? Give feedback.
-
Brillant, does exactly what I wanted, thanks, never would have figured that out but will be useful for future snippets. |
Beta Was this translation helpful? Give feedback.
Oh, interesting!
You can do
ie. manually clear the functionNode after jumping out of the
i(1)
.