Skip to content
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

chore: update tree-sitter, and add xml / dtd #614

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 34 additions & 33 deletions Cargo.lock

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

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ syntect = { version = "5.1.0", optional = true, default-features = false, featur
] }
ammonia = { version = "3.3.0", optional = true }

tree-sitter-highlight = { version = "0.20.1", optional = true }
tree-sitter-javascript = { version = "0.20.1", optional = true }
tree-sitter-typescript = { version = "0.20.3", optional = true }
tree-sitter-json = { version = "0.20.1", optional = true }
tree-sitter-regex = { version = "0.20.0", optional = true }
tree-sitter-css = { version = "0.20.0", optional = true }
tree-sitter-toml = { version = "0.20.0", optional = true }
tree-sitter-md = { version = "0.1.7", optional = true }
tree-sitter-rust = { version = "0.20.4", optional = true }
tree-sitter-html = { version = "0.20.0", optional = true }
tree-sitter-bash = { version = "0.20.5", optional = true }
tree-sitter-highlight = { version = "0.22.6", optional = true }
tree-sitter-javascript = { version = "0.21.4", optional = true }
tree-sitter-typescript = { version = "0.21.2", optional = true }
tree-sitter-json = { version = "0.21.0", optional = true }
tree-sitter-regex = { version = "0.21.0", optional = true }
tree-sitter-css = { version = "0.21.0", optional = true }
tree-sitter-md = { version = "0.2.3", optional = true }
tree-sitter-rust = { version = "0.21.2", optional = true }
tree-sitter-html = { version = "0.20.3", optional = true }
tree-sitter-bash = { version = "0.21.0", optional = true }
tree-sitter-xml = { version = "0.6.4", optional = true }

[dev-dependencies]
anyhow = { version = "1.0.58" }
Expand All @@ -84,11 +84,11 @@ tree-sitter = [
"tree-sitter-json",
"tree-sitter-regex",
"tree-sitter-css",
"tree-sitter-toml",
"tree-sitter-md",
"tree-sitter-rust",
"tree-sitter-html",
"tree-sitter-bash",
"tree-sitter-xml",
]

[[test]]
Expand Down
26 changes: 21 additions & 5 deletions src/html/tree_sitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ pub fn tree_sitter_language_cb(
"json" | "jsonc" => tree_sitter_language_json(),
"css" => tree_sitter_language_css(),
"md" | "markdown" => tree_sitter_language_markdown(),
"toml" => tree_sitter_language_toml(),
"xml" => tree_sitter_language_xml(),
"dtd" => tree_sitter_language_dtd(),
"regex" => tree_sitter_language_regex(),
"rs" | "rust" => tree_sitter_language_rust(),
"html" => tree_sitter_language_html(),
Expand Down Expand Up @@ -190,16 +191,31 @@ fn tree_sitter_language_markdown() -> &'static HighlightConfiguration {
})
}

fn tree_sitter_language_toml() -> &'static HighlightConfiguration {
fn tree_sitter_language_xml() -> &'static HighlightConfiguration {
static CONFIG: OnceLock<HighlightConfiguration> = OnceLock::new();
CONFIG.get_or_init(|| {
let mut config = HighlightConfiguration::new(
tree_sitter_toml::language(),
tree_sitter_toml::HIGHLIGHT_QUERY,
tree_sitter_xml::language_xml(),
tree_sitter_xml::XML_HIGHLIGHT_QUERY,
"",
"",
)
.expect("failed to initialize tree_sitter_toml highlighter");
.expect("failed to initialize tree_sitter_xml highlighter");
config.configure(CAPTURE_NAMES);
config
})
}

fn tree_sitter_language_dtd() -> &'static HighlightConfiguration {
static CONFIG: OnceLock<HighlightConfiguration> = OnceLock::new();
CONFIG.get_or_init(|| {
let mut config = HighlightConfiguration::new(
tree_sitter_xml::language_dtd(),
tree_sitter_xml::DTD_HIGHLIGHT_QUERY,
"",
"",
)
.expect("failed to initialize tree_sitter_dtd highlighter");
config.configure(CAPTURE_NAMES);
config
})
Expand Down
Loading