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

[feature] LSP: inform user when rule is invalid #722

Open
chrisgrieser opened this issue Nov 20, 2023 · 3 comments
Open

[feature] LSP: inform user when rule is invalid #722

chrisgrieser opened this issue Nov 20, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@chrisgrieser
Copy link

When you use ast-grep as LSP, you are not informed when the linting is not performed due to an invalid rule. Took me a while to come up with the idea to try ast-grep scan in the terminal, which revealed that an invalid rule was the cause:

> ast-grep scan
Error: Cannot parse rule {...}/short-var-names.yml
Help: The file is not a valid ast-grep rule. Please refer to doc and fix the error.
See also: https://ast-grep.github.io/guide/rule-config.html

✖ Caused by
╰▻ Fail to parse yaml as RuleConfig
╰▻ missing field `id` at line 11 column 1

I'd suggest displaying a diagnostic at line one with the info "invalid rule...", to inform the user why no linting is taking place.

@chrisgrieser chrisgrieser added the enhancement New feature or request label Nov 20, 2023
@HerringtonDarkholme
Copy link
Member

Thanks for the suggestion! It sounds like an LSP client feature to me. Are you using neovim?

@chrisgrieser
Copy link
Author

yeah, I am.

Nonetheless, I think simply adding a diagnostic stating "config invalid" would already help a lot, and that could be done without any changes on lsp client side?

@HerringtonDarkholme
Copy link
Member

The issue is that lsp only checks source code not config YAML.
It may be worth adding editing support for rule completion/diagnostic in LSP.

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

No branches or pull requests

2 participants