Closed JasonKleban closed 1 month ago
What language are you using? It's probably already mentioned in the doc
https://ast-grep.github.io/catalog/c/#match-function-call-in-c
Thanks! I'm using typescript (.ts files, not .tsx yet) and the commandline sg --pattern 'format($A)' --lang ts
is working for me. Just not the VSCode extension when (
)
are involved.
Please provide a minimal reproduction and also check your setting
OK, I found my way to this extension through a back alleyway and so I didn't know to fully set up the environment.
I guess perhaps a simple term doesn't require a working LSP but the parentheses do. Without the sgconfig.yml, the search for format
finds matches. Checking the ~hidden Output Log of "ast-grep" gave me the full diagnosis.
Side note: Could this empty sgconfig.yml just be assumed? Even with no ruleDirs set, it seems to work. It's not super nice to include a convenience extension's config file in a project root shared with others who might not use the extension.
Even with no ruleDirs set, it seems to work.
No, it doesn't work well with the empty file. And neither does sg
(silently finds no matches) but if I get rid of the sgconfig.yml sg
works again.
You have to have a valid configuration file or have no configuration at all
No, without a config file, the LSP won't start and the AST-GREP extension fails silently on all but simple patterns, as above. ("24 results in 10 files" for pattern format
)
I believe it's your problem. If you can help providing a minimal reproduction we can help you.
SG AST-GREP vscode is working for me in some cases (so it's wired up), but parentheses for a function call are not working. So pattern
format
works, but patternformat($A)
does not findformat(data)
for example. I'm on Windows, btw. I'm surprised I can't find any mention of this.