-
Notifications
You must be signed in to change notification settings - Fork 901
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
Switch to split markdown parser #3048
Switch to split markdown parser #3048
Conversation
Do you want to add yourself as a maintainer so people know whom to ping when things go wrong? |
Sure good idea |
Also, please don't forget to mark this as a breaking change ( |
I also noticed a bug (which probably should be solved separately from this PR): A node from an injected language used for highlighting can have a range that might include bytes that lie outside of the included range. E.g. with this
The emphasis spans over the second We would need to calculate the intersection between included range and node range for every node used in an injected language and use that instead. |
@MDeiml wow, awesome that we now have an |
I also think excluding children is the better default, but making this the default would probably need changes (and some discussion) in neovim itself. Maybe it's better to first test this directive here and later make a PR to neovim? |
a462a34
to
b35b32c
Compare
b35b32c
to
bf1ebcf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me otherwise :)
3d4058a
to
34ae4ac
Compare
Wrong alarm. I accidentally used the old markdown parser (was left installed as an artifact of testing a different PR at alternative install location). It seems to be slow still with |
34ae4ac
to
e795da2
Compare
It's a bit faster, but still slow. I think parsing time after edits is still linear with file size (should be linear with size of edit), because all inline ranges with more complicated elements like emphasis or code spans still get reparsed. This could be fixed, by detecting which inline ranges actually got edited and then just reusing the old trees for all the other ones. But that is something that tree-sitter itself should be able to detect, so maybe I'm gonna create a PR in for that in tree-sitter. |
Just on the off-chance: will tree-sitter/tree-sitter#1783 be of any help? |
I don't think so. There is no "syntactically wrong markdown", so error recovery is not relevant. |
- adding back nvim-markdown for syntax highlighting while queries downstream get updated to support the markdown split for markdown_inline - REF: nvim-treesitter/nvim-treesitter#3048
My new split markdown parser works quite well now (better than the non-split one). This PR changes the config to point at the new branch because I want to keep the old branch for now as other projects are using it.
It also adds some other changes that are needed for the two parsers to work:
exclude_children!
directive, that might also be very useful for something like Injected markdown incorrectly highlights indented docstrings #2212include_dir
option to parser configs (needed, because the two grammars don't live in the repos root directory)