cyrusfirheir / twee3-language-tools

[ VSCode extension ] Syntax highlighting and programmatic language tools for Twee 3, and Twine 2 storyformats.
https://marketplace.visualstudio.com/items?itemName=cyrusfirheir.twee3-language-tools
MIT License
47 stars 16 forks source link

Setting to restrict what macros can appear in a macro container #95

Open MinusGix opened 2 years ago

MinusGix commented 2 years ago

This is not overly common of a feature to want, but at times people have macros that should not do specific things inside them. One way to facilitate this would be to let the user specify a list of blacklisted child macros. It then scans over the tree to see if it appears inside of the macro.
An example usecase for this would be <<link>> when you specify a passage, and then disallowing using macros like <<goto>>. However this isn't trivial to implement, since it is dependent on which variant exists, and I don't believe the parsing information is paired with that in the right manner for it.
A basic version of this feature could be implemented, but the version that would be needed for <<link>> is rather complex.

BawdyInkSlinger commented 2 years ago

My goal with this comment is to suss out the config file UX for this. I have a macro that is pretty much a copy of link/button. Here is its config:

    act:
      name: act
      container: true
      parameters:
        - "text |+ passage"

Could we do this? (I'm not sure if yaml allows this, I think json could):

    act:
      name: act
      container: true
      parameters:
        - "text &+ passage"
          children:
            - "not(goto)"
        - "text"

I'm just spitballing here, but if this is reasonable, implementing not may be a feature in it of itself.

Alternatively:

    act:
      name: act
      container: true
      parameters:
        - "text &+ passage"
          forbidden_children:
            - "goto"
        - "text"