Replace tree-sitter highlighting code with Helix's impl#957
Merged
dzhou121 merged 1 commit intolapce:masterfrom Sep 10, 2022
Merged
Replace tree-sitter highlighting code with Helix's impl#957dzhou121 merged 1 commit intolapce:masterfrom
dzhou121 merged 1 commit intolapce:masterfrom
Conversation
This was referenced Sep 6, 2022
Closed
|
Quick reminder: helix is MPLv2 licensed so |
4f686d4 to
166e8c7
Compare
2eee5ad to
36c0eb5
Compare
This was referenced Sep 12, 2022
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This uses Helix's tree-sitter code, which is a modification of the official tree-sitter highlighter code to better support incremental highlighting. Rather than figuring out the details of what is needed for that and adapting our current method (which has issues because of it assuming you're only parsing one language at a time), we can use their code. (Which is under the MPL, but we can attribute the syntax.rs file to the helix project because it is a compatible license)
It might be nice to turn it into a crate some time, since for the most part it is relatively independent.
This also comes with a fix for markdown, since that's why I started on this whole change. The markdown crate is separated into
markdownandmarkdown.inline. Themarkdown(block) does basic parsing, then uses injections to do themarkdown.inlineparsing, which provides most of the highlighting.I store the language
HighlightConfigurationin a global lazy initialized instance. This was actually first change I made, because for injections we need to be able to get other language highlighters while we're highlighting some other language. TheRefCell<HashMap<LapceLanguage, HighlightConfiguration>>method wouldn't work for that, since we might need to modify it (to initialize a language) while there was an existing reference.Bugs: