Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injecting new grammar on top of vscode-language-babel issue #69

Open
akalajzi opened this issue Apr 25, 2020 · 0 comments
Open

Injecting new grammar on top of vscode-language-babel issue #69

akalajzi opened this issue Apr 25, 2020 · 0 comments

Comments

@akalajzi
Copy link

akalajzi commented Apr 25, 2020

Describe the issue

I'm writing a theme built on top of vscode-language-babel, and want to inject some specific tokens (ie, react hooks etc).
I've tested my extension and code against native reactjavascript/javascript language, and it works as expected; however with this extension active (which I'd like to have as its way better than native), I cannot seem to hook onto almost nothing apart from comments.
Ie, I'd like inject into scope entity.name.function and it just doesnt register.

Is there a way to do this?

Sample Code to Reproduce

{
  "scopeName": "ak.injection",
  "injectionSelector": "L:entity.name.function",
  "patterns": [
    {
      "include": "#hooks"
    }
  ],
  "repository": {
    "hooks": {
      "name": "extra.hook",
      "match": "(?<!\\w)(use\\w+)"
    }
  }
}

package.json snippet:

"contributes": {
...
    "grammars": [
      {
        "path": "./syntaxes/hooks.json",
        "scopeName": "ak.injection",
        "injectTo": [
          "source.js",
          "source.js.jsx",
          "source.jsx"
        ]
      }
    ]
  }

Screenshot of Current Behavior

It doesn't pick up injection:

fn_hook

Screenshot of Expected Behavior

However it does pick it up in comment block if I inject into meta.function.arrow. This is how I'd expect it to behave if I could inject into entity.name.function scope.

comment_useData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant