Skip to content

Regular expressions with end-of-line match #592

@weilbith

Description

@weilbith

Hey 👋🏾

I'm currently trying to improve my snippets as some of them expand automatically too often when it doesn't fit. Therefore I want to check if there is nothing in the line after the trigger. In theory this should be a simple end-of-line match in the trigger. But that doesn't work. Adding this makes the snippet never expand.

Here is an example. The trigger I was using so far was if[%( ]. So I simply added $ at the end of the trigger (see below). That doesn't work. To simplify the problem I also tried if $, but doesn't work neither.
Using ^ to match the start of the line works fine for me. No I'm unsure if this has something to do with how regular expressions are matched in the context of LuaSnip or if I don't understand a special case of the Lua expression syntax.

snippet(
  { trig = ' if[%( ]$', regTrig = true },
  if_node, -- ignore here to a simple example
}

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions