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

Tree-sitter grammar turns nested directives into block_quote #52

Open
wjakob opened this issue Mar 11, 2024 · 2 comments
Open

Tree-sitter grammar turns nested directives into block_quote #52

wjakob opened this issue Mar 11, 2024 · 2 comments
Labels
decision needed A decision needs to be taken to solve this upstream A problem originated from nvim-treesitter or tree-sitter

Comments

@wjakob
Copy link

wjakob commented Mar 11, 2024

In my continued quest of getting better syntax highlighting for Sphinx RST files, I've noticed that the tree-sitter-rst grammar sometimes turns sequences of nested directives into block_quote nodes (for the second, third, etc., sub-directive). It's possible that TreeSitter considers this to be a syntax/grammar error and that the presented tree is part of the minimum-error resolution strategy.

Screenshot 2024-03-11 at 13 38 22

Anyways, it would be great if the parser could at least accept nested directives, or allow me to inject RST into nodes by adding further queries on top of those provided by the tree-sitter-rst repository. But in this case, the problem is that the tree itself already has the wrong structure.

@stsewd
Copy link
Owner

stsewd commented Mar 11, 2024

This is a problem/limitation with injections on Neovim/TS. Neovim/tree-sitter don't expose an easy way to inject a "dedented range", since RST is sensitive to whitespace, the injected content results in a block quote.

I may try to see if there is a way to solve this from the parser side, like starting to track indents after the first nested indent.

@wjakob
Copy link
Author

wjakob commented Mar 11, 2024

This would be great, thank you. Many things can be done with queries within Neovim, but this isn't one of them.

@stsewd stsewd added decision needed A decision needs to be taken to solve this upstream A problem originated from nvim-treesitter or tree-sitter labels Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
decision needed A decision needs to be taken to solve this upstream A problem originated from nvim-treesitter or tree-sitter
Projects
None yet
Development

No branches or pull requests

2 participants