LuaSnip icon indicating copy to clipboard operation
LuaSnip copied to clipboard

No new empty line inserted

Open gruvw opened this issue 2 years ago • 2 comments

For some reason I can't make it insert an empty line.

"[G] New item": {
  "prefix": "itm",
  "body": [
    "",
    "\\item $0"
  ]
}

aaa itm| -> aaa \item |

Is there a work around

gruvw avatar Oct 05 '23 10:10 gruvw

Oh huh, that's weird, hadn't encountered that one before.. As a band-aid, you can use ls.parser.parse_snippet and the lua-loader to add that snippet, it'll be a tiny bit before I can look into this properly.

L3MON4D3 avatar Oct 05 '23 20:10 L3MON4D3

Thank you for your fast response. For reference, the following works as intended:

s({
  name = "[G] New item",
  trig = "itm",
  wordTrig = false,
}, {
  t({"", [[\item ]]}),
}),

gruvw avatar Oct 06 '23 06:10 gruvw

Hey, finally got around to fixing this :) Turns out, this was just because the parser removes leading/trailing newlines by default (useful for defining snippets in [[...]] while keeping indentation, bad when parsing snippets from vscode where a newline is very deliberate)

L3MON4D3 avatar Apr 02 '24 14:04 L3MON4D3