-
Notifications
You must be signed in to change notification settings - Fork 16
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
Tree-sitter tokens don't have any background colour #81
Comments
Proposed fix: #82 |
Rather than requiring a background colour to be specified for each syntax element, I'd prefer that the default background be used when one is missing. Otherwise all this does is "fix" the default config. For future issues, please bear in mind the advice given in the README of this repo and wait for a response to issues before raising PRs. |
Sure, no problem
Yeah, seems reasonable. |
The most straightforward way to achieve this seems to be to modify pub fn styles_for(&self, tag: &str) -> Styles {
let mut styles = match self.syntax.get(tag) {
Some(styles) => styles,
None => tag
.split_once('.')
.and_then(|(prefix, _)| self.syntax.get(prefix))
.or(self.syntax.get(TK_DEFAULT))
.expect("to have default styles"),
}
.clone();
// Use default colorscheme's background color if none is specified
if styles.bg.is_none() {
styles.bg = Some(self.bg);
}
styles
} Let me know whether this is an acceptable solution for this issue. |
I think that looks mostly alright but can we make the check and set the default once after loading config rather than on each access? This code gets called pretty frequently so keeping things as efficient as possible is a priority. There's definitely outstanding work around making this more efficient in general but I'd at least like to maintain the current performance where possible. |
The right place for setting default bg color for tree-sitter tokens seems to be inside of pub fn try_load() -> Result<Self, String> {
...
cfg.set_default_bg_for_tokens();
cfg.expand_home_dir_refs(&home);
Ok(cfg)
}
...
fn set_default_bg_for_tokens(&mut self) {
for style in self.colorscheme.syntax.values_mut() {
// Use default colorscheme's background color if none is specified
if style.bg.is_none() {
style.bg = Some(self.colorscheme.bg);
}
}
} Let me know whether my assumptions are correct and that is similar to what you had in mind. |
That looks reasonable 👍 |
PR: #86 |
Sorry @Romankivs, I didn't see that PR come through in my GitHub notifications. Thank you for this! |
Describe the bug
Tree-sitter tokens don't have any background colour.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Tree-sitter tokens are display with default background colour.
Screenshots
How it looks:
Versions & OS Details
The text was updated successfully, but these errors were encountered: