stsewd / tree-sitter-rst

reStructuredText grammar for tree-sitter
https://stsewd.dev/tree-sitter-rst/
MIT License
50 stars 7 forks source link

Code blocks #11

Closed WhyNotHugo closed 3 years ago

WhyNotHugo commented 3 years ago

Code blocks in RST don't seem to get highlighted properly, eg:

Title
========

.. code-block:: python

    print("hello world")  # This is not highlighted.

This sample clearly has some Python code in it. Is support for that something that needs to happen in this tree-sitter, or in the queries in nvim-treesitter?

stsewd commented 3 years ago

@WhyNotHugo hi, sorry for the late reply, injections are handled on the nvim-treesitter. The code-block directive is sphinx specific, that's why I haven't included them in the queries from nvim-treesitter, I do maintain those queries in another repo https://github.com/stsewd/sphinx.nvim#nvim-treesitter (https://github.com/stsewd/sphinx.nvim/blob/feb8ca4b58d27f14b51aad007090ad6c4195fd06/after/queries/rst/injections.scm#L15-L19)

WhyNotHugo commented 3 years ago

How about merging those queries into nvim-treesitter?

While they're not rst-standard, I can't image that being a problem. Worst-case scenario, it provides highlighting to someone who's typed that tag in a non-sphinx rst, which seems like a very odd thing to do.

And I can't say I've seen much rst usage that's not being used for sphinx.

Thoughs?

stsewd commented 3 years ago

I'm fine having that query upstream

stsewd commented 3 years ago

https://github.com/nvim-treesitter/nvim-treesitter/pull/1677