refactor: share language IDs with indentation configuration
This commit is contained in:
+7
-2
@@ -9,12 +9,16 @@ use tree_sitter::{
|
||||
mod languages;
|
||||
use languages::LanguageSpec;
|
||||
|
||||
pub(crate) const RUST_ID: &str = "rust";
|
||||
pub(crate) const RUBY_ID: &str = "ruby";
|
||||
pub(crate) const PYTHON_ID: &str = "python";
|
||||
|
||||
pub(crate) fn is_markdown_path(path: &Path) -> bool {
|
||||
languages::detect(Some(path), None).is_some_and(|syntax| syntax.name == "Markdown")
|
||||
}
|
||||
|
||||
pub(crate) fn language_name(path: Option<&Path>, first_line: Option<&str>) -> Option<&'static str> {
|
||||
languages::detect(path, first_line).map(|syntax| syntax.name)
|
||||
pub(crate) fn language_id(path: Option<&Path>, first_line: Option<&str>) -> Option<&'static str> {
|
||||
languages::detect(path, first_line).map(|syntax| syntax.id)
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
@@ -2120,6 +2124,7 @@ mod tests {
|
||||
"((identifier) @function (#unsupported? @function))",
|
||||
]
|
||||
.map(|query| LanguageSpec {
|
||||
id: language.id,
|
||||
name: "invalid test grammar query",
|
||||
language: language.language.clone(),
|
||||
highlights: query,
|
||||
|
||||
Reference in New Issue
Block a user