Skip to content

Support placeholder expansion inside of eval #145

Description

@thalesmello

Problem Statement

Some configs snippet expansions I want to do would require expanding the placeholder inside of the eval expression. Would be possible to support that as a feature?

An example of what I'm trying to accomplish, basically to break the line automatically if I hit enter in the $2 placeholder.

snippet f "Anonymous function" i
    function (${1})${2: }$3 `!lua "$2" == "\n" and "\n" or ""`end${0}

Ideas or possible solutions

I think it could maybe be solved by expanding $2 inside the string of the enclosed eval expression, but that would require re-evaluating the eval expression each time the placeholders are updated.

Alternatives you have considered

Alternatively, this could be exposed as a function call:

snippet f "Anonymous function" i
    function (${1})${2: }$3 `!lua require("snippy").expand("$2") == "\n" and "\n" or ""`end${0}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions