Skip to content

Commit f8efea4

Browse files
committed
tweaks to highlighting and colorscheme
1 parent 33e34f3 commit f8efea4

File tree

3 files changed

+44
-34
lines changed

3 files changed

+44
-34
lines changed

data/config.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,17 @@ exec = { fg = "#E6D29E", bg = "#Bf616A" }
6767
boolean = { fg = "#DCA561", bold = true }
6868
character = { fg = "#61DCA5", italic = true }
6969
comment = { fg = "#624354", italic = true }
70-
constant = { fg = "#FF9E3B" }
71-
function = { fg = "#957FB8" }
70+
constant = { fg = "#FFA066" }
71+
function = { fg = "#8793B5" }
72+
"function.macro" = { fg = "#FFA066" }
7273
keyword = { fg = "#Bf616A" }
7374
module = { fg = "#2D4F67" }
7475
number = { fg = "#D27E99" }
75-
operator = { fg = "#E6C384" }
76+
operator = { fg = "#DCA561" }
7677
punctuation = { fg = "#9CABCA" }
7778
string = { fg = "#61DCA5" }
78-
type = { fg = "#7E9CD8" }
79-
variable = { fg = "#E6C384" }
79+
type = { fg = "#9AB292" }
80+
variable = { fg = "#E6D29E" }
8081

8182

8283
# Key mappings to programs that must be available on $PATH or commands.

data/tree-sitter/queries/rust/highlights.scm

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
(shebang) @keyword.directive
22

3-
(function_item (identifier) @function)
4-
(function_signature_item (identifier) @function)
5-
(macro_invocation
6-
macro: (identifier) @function.macro
7-
"!" @function.macro)
8-
93
(identifier) @variable
104

115
; Assume all-caps names are constants
@@ -24,12 +18,35 @@
2418
name: (identifier) @module)
2519
(self) @keyword.builtin
2620

21+
(function_item (identifier) @function)
22+
(function_signature_item (identifier) @function)
23+
(macro_invocation
24+
macro: (identifier) @function.macro
25+
"!" @function.macro)
26+
27+
(call_expression
28+
function: (identifier) @function.call)
29+
(call_expression
30+
function: (scoped_identifier
31+
(identifier) @function.call .))
32+
(call_expression
33+
function: (field_expression
34+
field: (field_identifier) @function.call))
35+
(generic_function
36+
function: (identifier) @function.call)
37+
(generic_function
38+
function: (scoped_identifier
39+
name: (identifier) @function.call))
40+
(generic_function
41+
function: (field_expression
42+
field: (field_identifier) @function.call))
43+
2744
[
2845
(line_comment)
2946
(block_comment)
3047
(outer_doc_comment_marker)
3148
(inner_doc_comment_marker)
32-
] @comment @spell
49+
] @comment
3350

3451
(line_comment
3552
(doc_comment)) @comment.documentation

src/config.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,20 @@ impl Config {
7777
Err(e) => return Err(format!("Unable to load config file: {e}")),
7878
};
7979

80-
cfg.set_default_bg_for_tokens();
81-
cfg.expand_home_dir_refs(&home);
80+
// Use default colorscheme's background color if none is specified
81+
for style in cfg.colorscheme.syntax.values_mut() {
82+
style.bg = style.bg.or(Some(cfg.colorscheme.bg));
83+
}
84+
85+
// Replace "~/" shorthand notation in paths with the user's $HOME
86+
for s in [
87+
&mut cfg.tree_sitter.parser_dir,
88+
&mut cfg.tree_sitter.syntax_query_dir,
89+
] {
90+
if s.starts_with("~/") {
91+
*s = s.replacen("~", &home, 1);
92+
}
93+
}
8294

8395
Ok(cfg)
8496
}
@@ -103,26 +115,6 @@ impl Config {
103115

104116
Err("runtime config updates are not currently supported".to_owned())
105117
}
106-
107-
fn set_default_bg_for_tokens(&mut self) {
108-
for style in self.colorscheme.syntax.values_mut() {
109-
// Use default colorscheme's background color if none is specified
110-
if style.bg.is_none() {
111-
style.bg = Some(self.colorscheme.bg);
112-
}
113-
}
114-
}
115-
116-
fn expand_home_dir_refs(&mut self, home: &str) {
117-
for s in [
118-
&mut self.tree_sitter.parser_dir,
119-
&mut self.tree_sitter.syntax_query_dir,
120-
] {
121-
if s.starts_with("~/") {
122-
*s = s.replacen("~", home, 1);
123-
}
124-
}
125-
}
126118
}
127119

128120
/// A colorscheme for rendering the UI.

0 commit comments

Comments
 (0)