diff --git a/data/config.toml b/data/config.toml index 3cbc283..64f37e8 100644 --- a/data/config.toml +++ b/data/config.toml @@ -67,16 +67,17 @@ exec = { fg = "#E6D29E", bg = "#Bf616A" } boolean = { fg = "#DCA561", bold = true } character = { fg = "#61DCA5", italic = true } comment = { fg = "#624354", italic = true } -constant = { fg = "#FF9E3B" } -function = { fg = "#957FB8" } +constant = { fg = "#FFA066" } +function = { fg = "#8793B5" } +"function.macro" = { fg = "#FFA066" } keyword = { fg = "#Bf616A" } module = { fg = "#2D4F67" } number = { fg = "#D27E99" } -operator = { fg = "#E6C384" } +operator = { fg = "#DCA561" } punctuation = { fg = "#9CABCA" } string = { fg = "#61DCA5" } -type = { fg = "#7E9CD8" } -variable = { fg = "#E6C384" } +type = { fg = "#9AB292" } +variable = { fg = "#E6D29E" } # Key mappings to programs that must be available on $PATH or commands. diff --git a/data/tree-sitter/queries/rust/highlights.scm b/data/tree-sitter/queries/rust/highlights.scm index e1135f9..7c03474 100644 --- a/data/tree-sitter/queries/rust/highlights.scm +++ b/data/tree-sitter/queries/rust/highlights.scm @@ -1,11 +1,5 @@ (shebang) @keyword.directive -(function_item (identifier) @function) -(function_signature_item (identifier) @function) -(macro_invocation - macro: (identifier) @function.macro - "!" @function.macro) - (identifier) @variable ; Assume all-caps names are constants @@ -24,12 +18,35 @@ name: (identifier) @module) (self) @keyword.builtin +(function_item (identifier) @function) +(function_signature_item (identifier) @function) +(macro_invocation + macro: (identifier) @function.macro + "!" @function.macro) + +(call_expression + function: (identifier) @function.call) +(call_expression + function: (scoped_identifier + (identifier) @function.call .)) +(call_expression + function: (field_expression + field: (field_identifier) @function.call)) +(generic_function + function: (identifier) @function.call) +(generic_function + function: (scoped_identifier + name: (identifier) @function.call)) +(generic_function + function: (field_expression + field: (field_identifier) @function.call)) + [ (line_comment) (block_comment) (outer_doc_comment_marker) (inner_doc_comment_marker) -] @comment @spell +] @comment (line_comment (doc_comment)) @comment.documentation diff --git a/src/config.rs b/src/config.rs index 940430a..8e3e01d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -77,8 +77,20 @@ impl Config { Err(e) => return Err(format!("Unable to load config file: {e}")), }; - cfg.set_default_bg_for_tokens(); - cfg.expand_home_dir_refs(&home); + // Use default colorscheme's background color if none is specified + for style in cfg.colorscheme.syntax.values_mut() { + style.bg = style.bg.or(Some(cfg.colorscheme.bg)); + } + + // Replace "~/" shorthand notation in paths with the user's $HOME + for s in [ + &mut cfg.tree_sitter.parser_dir, + &mut cfg.tree_sitter.syntax_query_dir, + ] { + if s.starts_with("~/") { + *s = s.replacen("~", &home, 1); + } + } Ok(cfg) } @@ -103,26 +115,6 @@ impl Config { Err("runtime config updates are not currently supported".to_owned()) } - - 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); - } - } - } - - fn expand_home_dir_refs(&mut self, home: &str) { - for s in [ - &mut self.tree_sitter.parser_dir, - &mut self.tree_sitter.syntax_query_dir, - ] { - if s.starts_with("~/") { - *s = s.replacen("~", home, 1); - } - } - } } /// A colorscheme for rendering the UI.