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

RST grammar not injected into sub-directives #51

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

RST grammar not injected into sub-directives #51

wjakob opened this issue Mar 8, 2024 · 2 comments
Labels
upstream A problem originated from nvim-treesitter or tree-sitter

Comments

@wjakob
Copy link

wjakob commented Mar 8, 2024

The current version of the tree-sitter RST parser does not process RST grammar embedded into directives like .. warning::, .. note::, etc. See here for an example of such a document and the parse tree shown in NVIM. Note the absent syntax highlighting of the reference.

Screenshot 2024-03-08 at 22 06 48

Curiously, it works when the directive is further annotated:
Screenshot 2024-03-08 at 22 08 00

PS: I am skeptical if the document element makes sense occurring within the tree in this way. When I try to add a custom tree-sitter rule that matches on this element to manually inject the RST grammar into document, I get an error message from NVIM saying that the following structure is impossible.

Screenshot 2024-03-08 at 22 11 42
@stsewd
Copy link
Owner

stsewd commented Mar 10, 2024

PS: I am skeptical if the document element makes sense occurring within the tree in this way. When I try to add a custom tree-sitter rule that matches on this element to manually inject the RST grammar into document, I get an error message from NVIM saying that the following structure is impossible.

That's because document is part of the injected tree, not from the original one. Neovim basically injects rst inside rst.

Curiously, it works when the directive is further annotated:

That's probably a bug in the injection queries from nvim-treesitter, I'll look into that in following days/weeks.

@wjakob
Copy link
Author

wjakob commented Mar 11, 2024

That's because document is part of the injected tree, not from the original one. Neovim basically injects rst inside rst.

Makes sense!

That's probably a bug in the injection queries from nvim-treesitter, I'll look into that in following days/weeks.

Great, thank you! ❤️

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

No branches or pull requests

2 participants