Skip to content

Stable snippets #443

@pokey

Description

@pokey

The problem

The tab stops in VSCode's snippet interface can be a bit fragile, especially when combining them with cursorless commands. If you're not careful, vscode will decide that you're no longer in a snippet and drop all the tab stops.

In addition, VSCode snippets have no way of indicating how a snippet hole should expand as text is inserted and the code around it changes. Should it expand in both directions? Should it expand to match a particular syntactic scope (eg the syntax node corresponding to the condition of an if statement)?

Having an extremely stable version of snippets where the tab stops don't go away even if you switch to a different file could also enable some interesting workflows where you set up a snippet and then navigate from file to file adding things to a snippet body that is still in the background

We'd like an experience which is similar to the way that holes work in agda.

Implementation

  • When cursorless inserts a snippet, instead of using the built-in vscode snippet engine, it will insert the text of the snippet and then use decorations to indicate the different holes in the snippet
  • Snippets will be able to indicate how to update the range of each hole, for example open on one side closed on the other, expanding according to regex, expanding to a particular scope type such as "condition", etc
  • Add marks corresponding to all the different holes of a snippet, eg "snip condition", etc. The marks could potentially be active even if the editor is not visible

References

We should take a look at https://github.com/ethan-leba/tree-edit

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions