-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Rainbow tree-sitter matches 🌈 #2857
base: master
Are you sure you want to change the base?
Rainbow tree-sitter matches 🌈 #2857
Commits on Jan 11, 2024
-
Parse rainbow style array in themes
This change adds a field to the schema of themes which takes a list of styles. rainbow = ["red", "orange", "yellow", { modifiers = ["reversed"] }] [palette] red = "#ff0000" orange = "#ffa500" yellow = "#fff000" Normal style rules apply for each element in `rainbows`: you can use definitions from the palette and the full fg/bg/modifiers notation. Themes written with `rainbow` keys are not backwards compatible. Parsing errors will be generated for older versions of Helix attempting to use themes with `rainbow` keys. A default rainbow is provided with base16 colors. This change is made with rainbow pair characters (parens, brackets, etc.) in mind but it could also be used for other rainbow cosmetic elements like rainbow indent-guides.
Configuration menu - View commit details
-
Copy full SHA for a2760bf - Browse repository at this point
Copy the full SHA a2760bfView commit details -
Add rainbow_brackets configuration option
This option is similar to the `rulers` config: it can be set no the editor key in config and also overridden for specific languages, so you could enable rainbow brackets for lisps for example without enabling it globally.
Configuration menu - View commit details
-
Copy full SHA for dae731a - Browse repository at this point
Copy the full SHA dae731aView commit details -
Configuration menu - View commit details
-
Copy full SHA for d5bfab7 - Browse repository at this point
Copy the full SHA d5bfab7View commit details -
Add a generic iterator over captures across injections
This can be used to calculate rainbow highlights (see the child commit) or indents or textobjects and be accurate to the injected content rather than just the root layer. This is useful for languages which use injections heavily like Vue or JavaScript within HTML but are also useful in common scenarios like within codeblocks in Markdown. This iterator shares some code with the HighlightIter and HighlightIterLayer but that iterator emits HighlightEvents, so it cares about the beginnings and ends of highlight events rather than captures.
Configuration menu - View commit details
-
Copy full SHA for 04c7304 - Browse repository at this point
Copy the full SHA 04c7304View commit details -
Calculate rainbow highlights spans
This is an example usage of the query_iter introduced in the parent commit: captures are returned in order across language layers. We can use this iterator and a stack for the rainbow scopes to calculate highlight spans that can be merged into the syntax highlights using syntax::merge.
Configuration menu - View commit details
-
Copy full SHA for 8e3d43d - Browse repository at this point
Copy the full SHA 8e3d43dView commit details -
Overlay rainbow highlights onto syntax highlights
We call the rainbow_spans function introduced in the parent commits over the largest node that contains the current viewport: we need to reach far enough back in the document that we find the absolute beginning for brackets. If we run rainbow_spans only over the current viewport, we get a bug where the color of rainbow brackets changes as we move the viewport.
Configuration menu - View commit details
-
Copy full SHA for 26625d1 - Browse repository at this point
Copy the full SHA 26625d1View commit details
Commits on Jan 12, 2024
-
Co-authored-by: SoraTenshi <dream@neoncity.dev>
Configuration menu - View commit details
-
Copy full SHA for b6669ad - Browse repository at this point
Copy the full SHA b6669adView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0978b47 - Browse repository at this point
Copy the full SHA 0978b47View commit details -
Configuration menu - View commit details
-
Copy full SHA for 93b7190 - Browse repository at this point
Copy the full SHA 93b7190View commit details -
Share sort_key function between query iterators
This is brings the fix from d5f17d3 to the QueryIter layers. A trait for getting the cursor and sort-key from each layer helps cut down on code duplicated between these iterators.
Configuration menu - View commit details
-
Copy full SHA for 75f4f4a - Browse repository at this point
Copy the full SHA 75f4f4aView commit details -
Share sort_layers function between query iterators
The code in the `sort_layers` function was fully duplicated between the HighlightIter and the QueryIter. This change adds a common `sort_layers` function that accepts a layer Vec from both.
Configuration menu - View commit details
-
Copy full SHA for 410a2b2 - Browse repository at this point
Copy the full SHA 410a2b2View commit details -
Use a helper function for creating query captures
This deduplicates some somewhat complex code between the highlight_iter and query_iter.
Configuration menu - View commit details
-
Copy full SHA for ca4417c - Browse repository at this point
Copy the full SHA ca4417cView commit details -
Mark query_captures function as unsafe
It's easy to mistakenly use-after-free the cursor and captures iterator here because of the transmute. Ideally this could be fixed upstream in tree-sitter by introducing an API with lifetimes/types that reflect the lifetimes of the underlying data. Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
Configuration menu - View commit details
-
Copy full SHA for 35d707d - Browse repository at this point
Copy the full SHA 35d707dView commit details