atom / snippets

Atom snippets package
MIT License
206 stars 102 forks source link

Make snippets LSP compliant #285

Open Aerijo opened 5 years ago

Aerijo commented 5 years ago

Description

There are a few features of snippets that are missing. E.g., choices and variables. This issue is to request the snippet implmentation be changed / improved to implement the rules as described below here.

While improving Atom's own snippet handling, it also makes it easier to use completions provided by language servers directly. Technically, they should currently be sanitised to remove unsupported features.

In summary (some of this is already implemented):

I'm not sure how the current \u and friends fit in, but could potentially be an enhancement if not already supported by the regex.

Here's the EBNF grammar provided in the link

any         ::= tabstop | placeholder | choice | variable | text
tabstop     ::= '$' int | '${' int '}'
placeholder ::= '${' int ':' any '}'
choice      ::= '${' int '|' text (',' text)* '|}'
variable    ::= '$' var | '${' var }'
                | '${' var ':' any '}'
                | '${' var '/' regex '/' (format | text)+ '/' options '}'
format      ::= '$' int | '${' int '}'
                | '${' int ':' '/upcase' | '/downcase' | '/capitalize' '}'
                | '${' int ':+' if '}'
                | '${' int ':?' if ':' else '}'
                | '${' int ':-' else '}' | '${' int ':' else '}'
regex       ::= JavaScript Regular Expression value (ctor-string)
options     ::= JavaScript Regular Expression option (ctor-options)
var         ::= [_a-zA-Z] [_a-zA-Z0-9]*
int         ::= [0-9]+
text        ::= .*
LoganTann commented 2 years ago

I'd love a choice placeholder. Currently, I have to use an autocomplete+ provider, but it's hard to implement.