Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Make snippets LSP compliant #285

Open
Aerijo opened this issue Dec 28, 2018 · 1 comment
Open

Make snippets LSP compliant #285

Aerijo opened this issue Dec 28, 2018 · 1 comment

Comments

@Aerijo
Copy link
Contributor

Aerijo commented Dec 28, 2018

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):

  • Tab stops: $n for cursor locations
  • Placeholders: ${1:foo} for preselected placeholder values
  • Nested placeholders: Support of ${1:foo ${2:bar}} is required
  • Choice: ${|one,two,three|} prompts the user to pick a value (not sure how prompt should work)
  • Variables: Allows replacements to use context such as file name, selected text, etc.
  • Variable transforms: Regex applied to variables.

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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants