loader: use portable way of path joining

This commit is contained in:
Andrew Hlynskyi 2023-01-11 04:11:04 +02:00
parent 2949b210b9
commit f627a97d24
2 changed files with 6 additions and 3 deletions

View file

@ -37,7 +37,8 @@ impl Config {
let legacy_path = dirs::home_dir()
.ok_or(anyhow!("Cannot determine home directory"))?
.join(".tree-sitter/config.json");
.join(".tree-sitter")
.join("config.json");
if legacy_path.is_file() {
return Ok(Some(legacy_path));
}
@ -48,7 +49,8 @@ impl Config {
fn xdg_config_file() -> Result<PathBuf> {
let xdg_path = dirs::config_dir()
.ok_or(anyhow!("Cannot determine config directory"))?
.join("tree-sitter/config.json");
.join("tree-sitter")
.join("config.json");
Ok(xdg_path)
}

View file

@ -112,7 +112,8 @@ impl Loader {
Ok(path) => PathBuf::from(path),
_ => dirs::cache_dir()
.ok_or(anyhow!("Cannot determine cache directory"))?
.join("tree-sitter/lib"),
.join("tree-sitter")
.join("lib"),
};
Ok(Self::with_parser_lib_path(parser_lib_path))
}