From aeb239016668c48e745c5644f296b9e7adc54feb Mon Sep 17 00:00:00 2001 From: Thomas Churchman Date: Fri, 3 May 2024 13:45:53 +0200 Subject: [PATCH] feat: add TOML syntax highlighting --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + src/highlight.rs | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 2e4d3f3..9cee669 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1369,6 +1369,7 @@ dependencies = [ "tree-sitter-nix", "tree-sitter-python", "tree-sitter-rust", + "tree-sitter-toml", "tree-sitter-typescript", "walkdir", ] @@ -1633,6 +1634,16 @@ dependencies = [ "tree-sitter", ] +[[package]] +name = "tree-sitter-toml" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca517f578a98b23d20780247cc2688407fa81effad5b627a5a364ec3339b53e8" +dependencies = [ + "cc", + "tree-sitter", +] + [[package]] name = "tree-sitter-typescript" version = "0.20.5" diff --git a/Cargo.toml b/Cargo.toml index e1e0355..cc2ba30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ tree-sitter-nix = "0.0.1" tree-sitter-javascript = "0.20" tree-sitter-python = "0.20" tree-sitter-rust = "0.20" +tree-sitter-toml = "0.20" tree-sitter-typescript = "0.20" latex2mathml = { version = "0.2", optional = true } diff --git a/src/highlight.rs b/src/highlight.rs index 379905b..af9f593 100644 --- a/src/highlight.rs +++ b/src/highlight.rs @@ -102,6 +102,12 @@ fn init_configurations() -> Box { })); rust_config.configure(HIGHLIGHT_NAMES); + let toml_config = Box::leak::<'static>(Box::new({ + let highlights = tree_sitter_toml::HIGHLIGHT_QUERY; + HighlightConfiguration::new(tree_sitter_toml::language(), &highlights, "", "").unwrap() + })); + toml_config.configure(HIGHLIGHT_NAMES); + let typescript_config = Box::leak::<'static>(Box::new({ let highlights: String = [ tree_sitter_javascript::HIGHLIGHT_QUERY, @@ -133,6 +139,7 @@ fn init_configurations() -> Box { "nix" => Some(nix_config as &'static _), "python" => Some(python_config as &'static _), "rust" => Some(rust_config as &'static _), + "toml" => Some(toml_config as &'static _), "typescript" | "ts" | "javascript" | "js" => Some(typescript_config as &'static _), _ => None, };