nvim-snippy icon indicating copy to clipboard operation
nvim-snippy copied to clipboard

Support choices mixed with vim functions

Open kassio opened this issue 3 years ago • 3 comments

First of all, thanks! Great plugin!

Would it be possible to enable the plugin to support mixed vim functions and static texts in the placeholder choices? Something like:

snippet today
  ${1|`strftime('%c')`,today|}

kassio avatar Jan 26 '22 12:01 kassio

First of all, thanks! Great plugin!

Thanks!

Would it be possible to enable the plugin to support mixed vim functions and static texts in the placeholder choices?

I think it would be possible, but I don't know how easily it could be added without increasing the complexity of the parser. If someone comes up with a simple solution, I'd happily review/accept a pull request.

On the plus side, I think it would be a feature unique to Snippy, which might make it worth adding.

dcampos avatar Feb 02 '22 00:02 dcampos

I think eval elements should be parsed separately and replaced with the evaluated strings/lines, then the parser would parse the rest.

mg979 avatar Feb 02 '22 00:02 mg979

Another idea, that I'm not sure if better or worse, but lua supports functions with multiple returns, so maybe we could do something like:

function foo()
  return 1, 2, 3
end
snippet today
  ${1|`foo()`|}

kassio avatar Aug 09 '23 18:08 kassio