diff --git a/cli/loader/src/lib.rs b/cli/loader/src/lib.rs index 9b91be7e..2c188582 100644 --- a/cli/loader/src/lib.rs +++ b/cli/loader/src/lib.rs @@ -62,12 +62,12 @@ pub struct Config { pub enum PathsJSON { #[default] Empty, - Single(String), - Multiple(Vec), + Single(PathBuf), + Multiple(Vec), } impl PathsJSON { - fn into_vec(self) -> Option> { + fn into_vec(self) -> Option> { match self { Self::Empty => None, Self::Single(s) => Some(vec![s]), @@ -306,10 +306,10 @@ pub struct LanguageConfiguration<'a> { pub injection_regex: Option, pub file_types: Vec, pub root_path: PathBuf, - pub highlights_filenames: Option>, - pub injections_filenames: Option>, - pub locals_filenames: Option>, - pub tags_filenames: Option>, + pub highlights_filenames: Option>, + pub injections_filenames: Option>, + pub locals_filenames: Option>, + pub tags_filenames: Option>, pub language_name: String, language_id: usize, #[cfg(feature = "tree-sitter-highlight")] @@ -1395,7 +1395,7 @@ impl LanguageConfiguration<'_> { pub fn highlight_config( &self, language: Language, - paths: Option<&[String]>, + paths: Option<&[PathBuf]>, ) -> Result> { let (highlights_filenames, injections_filenames, locals_filenames) = match paths { Some(paths) => ( @@ -1545,7 +1545,7 @@ impl LanguageConfiguration<'_> { #[cfg(any(feature = "tree-sitter-highlight", feature = "tree-sitter-tags"))] fn include_path_in_query_error( mut error: QueryError, - ranges: &[(String, Range)], + ranges: &[(PathBuf, Range)], source: &str, start_offset: usize, ) -> Error { @@ -1565,9 +1565,9 @@ impl LanguageConfiguration<'_> { #[cfg(any(feature = "tree-sitter-highlight", feature = "tree-sitter-tags"))] fn read_queries( &self, - paths: Option<&[String]>, + paths: Option<&[PathBuf]>, default_path: &str, - ) -> Result<(String, Vec<(String, Range)>)> { + ) -> Result<(String, Vec<(PathBuf, Range)>)> { let mut query = String::new(); let mut path_ranges = Vec::new(); if let Some(paths) = paths { @@ -1594,7 +1594,7 @@ impl LanguageConfiguration<'_> { if path.exists() { query = fs::read_to_string(&path) .with_context(|| format!("Failed to read query file {path:?}"))?; - path_ranges.push((default_path.to_string(), 0..query.len())); + path_ranges.push((PathBuf::from(default_path), 0..query.len())); } } diff --git a/cli/src/main.rs b/cli/src/main.rs index c2a30106..922534d6 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -379,7 +379,7 @@ struct Highlight { pub captures_path: Option, /// The paths to files with queries #[arg(long, num_args = 1..)] - pub query_paths: Option>, + pub query_paths: Option>, /// Select a language by the scope instead of a file extension #[arg(long)] pub scope: Option,