Replies: 1 comment
-
You may find it unintuitive but Yasnippet is more than a decade old and copies the syntax of the Textmate editor quite precisely. It wouldn't matter anyway, but I would be suprised if Textmate didn't interpret those fields the same way. LSP, on the other hand, is a much more recent invention, which happens to also inherit Textmate snippet syntax coincidentally, but not exactly in the same way that Yasnippt does. If the two syntaxes don't coincide, it's a shame. I think something along the lines you're proposing is a reasonable addition to eglot.el. Submit a bug report to [email protected] attaching a patch to Emacs's |
Beta Was this translation helpful? Give feedback.
-
For snippet completion, Eglot calls
yas-expand-snippet
. This works in most cases, but there are some differences between the syntax LSP specifies and the syntax Yasnippet supports.LSP allows a simple tabstop to be specified as either
$1
or${1}
. Both mean the same thing. All examples in the specification use the first syntax, and most LSP servers seem to do the same, but the grammar also allows the second. Phpactor uses the second syntax.Yasnippet doesn't consider the second syntax as a simple tabstop, but as a numberless tabstop with a default value (the number).
(Personally I find this unintuitive, and when the documentation says "The number can be omitted" I would expect the colon to still be required to specify a default value, but if you use
${:value}
the default value will be:value
.)I've locally worked around this by adding the following to my init file:
Should something like this be included in Eglot? It would be more complete to convert the full syntax LSP specifies to a Yasnippet equivalent, but I don't know of any servers that use choice values, variables or variable transforms.
Beta Was this translation helpful? Give feedback.
All reactions