smjonas / snippet-converter.nvim

Bundle snippets from multiple sources and convert them to your format of choice.
Mozilla Public License 2.0
170 stars 4 forks source link

Some snippets do not expand after conversion #7

Closed doubleChu closed 2 years ago

doubleChu commented 2 years ago

In #6 I have done a conversion from vscode_luasnip to vscode_luasnip to replace some snippets. Date snippets like "${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}" is converted to Vimscript like "`!v !v strftime('%Y')`-`!v strftime('%m')`-`!v strftime('%b')`" When I tried to expand 'date', this would be plain text as same as the code above. L3MON4D3/LuaSnip#283 shows that LuaSnip does not support this until L3MON4D3/LuaSnip#445 is merged. I checked the source code and here is my advice:

  1. in lua/snippet_converter/core/converter.lua, this line: [Variable.CURRENT_YEAR] = [[`!v !v strftime('%Y')`]] seems to repeat !v twice, is that a syntax error ?
  2. If both my sources and output use the same engine as LuaSnip, is it unnecessary to make such a conversion ?

Moreover, have you ever considered to add an option to not automatically generate the required package.json file in the root directory ? Cuz if what I want to do is replace the snippets rather than generate the text for a different engine, I can choose to disable it.

smjonas commented 2 years ago

Those are all very good suggestions, thank you! Finally there is some engagement with this plugin :D

seems to repeat !v twice, is that a syntax error ?

Yes it is, good catch!

is it unnecessary to make such a conversion ?

Absolutely, I haven't thought about this edge case, there is no need for an extra conversion step to Vimscript.

It may take a week or so until I have some time to work on this though, I'll let you know!