Skip to content

Commit

Permalink
feat: add TOML syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcur committed May 3, 2024
1 parent 1d1ed53 commit aeb2390
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
7 changes: 7 additions & 0 deletions src/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ fn init_configurations() -> Box<Configurations> {
}));
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,
Expand Down Expand Up @@ -133,6 +139,7 @@ fn init_configurations() -> Box<Configurations> {
"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,
};
Expand Down

0 comments on commit aeb2390

Please sign in to comment.