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

Make snippets LSP compliant #285

Open
@Aerijo

Description

@Aerijo

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        ::= .*

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions