⭐ Suggestion
The LSP currently doesn't report diagnostics for rules targeting injected languages. For example, given a config with language injections:
customLanguages:
scss:
libraryPath: ./lib/scss.so
extensions: [scss]
languageSymbol: tree_sitter_scss
sassdoc:
libraryPath: ./lib/sassdoc.so
extensions: [sassdoc]
languageInjections:
- hostLanguage: scss
rule:
pattern:
context: '/// $CONTENT'
selector: sassdoc_line
injected: sassdoc
Rules targeting sassdoc are correctly matched by ast-grep scan, but the LSP returns empty diagnostics for the same files. The CLI handles this in filter_file_rule by calling get_injections() on the parsed tree and scanning each injected sub-tree separately, but the LSP's get_versioned_ast only parses the host language tree.
💻 Use Cases
I'm currently working around this in Neovim by running ast-grep scan --json=stream as an external linter via nvim-lint, but it would be great to have this work natively through the LSP so editors that don't support custom external linters (like Zed or VScode) can also benefit.
⭐ Suggestion
The LSP currently doesn't report diagnostics for rules targeting injected languages. For example, given a config with language injections:
Rules targeting
sassdocare correctly matched byast-grep scan, but the LSP returns empty diagnostics for the same files. The CLI handles this infilter_file_ruleby callingget_injections()on the parsed tree and scanning each injected sub-tree separately, but the LSP'sget_versioned_astonly parses the host language tree.💻 Use Cases
I'm currently working around this in Neovim by running
ast-grep scan --json=streamas an external linter vianvim-lint, but it would be great to have this work natively through the LSP so editors that don't support custom external linters (like Zed or VScode) can also benefit.