-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for local language configuration (#1249)
* add local configuration * move config loading to Application::new * simplify find_root_impl
- Loading branch information
Showing
10 changed files
with
102 additions
and
89 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
/// Syntax configuration loader based on built-in languages.toml. | ||
pub fn default_syntax_loader() -> crate::syntax::Configuration { | ||
helix_loader::default_lang_config() | ||
helix_loader::config::default_lang_config() | ||
.try_into() | ||
.expect("Could not serialize built-in languages.toml") | ||
} | ||
/// Syntax configuration loader based on user configured languages.toml. | ||
pub fn user_syntax_loader() -> Result<crate::syntax::Configuration, toml::de::Error> { | ||
helix_loader::user_lang_config()?.try_into() | ||
helix_loader::config::user_lang_config()?.try_into() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/// Default bultin-in languages.toml. | ||
pub fn default_lang_config() -> toml::Value { | ||
toml::from_slice(include_bytes!("../../languages.toml")) | ||
.expect("Could not parse bultin-in languages.toml to valid toml") | ||
} | ||
|
||
/// User configured languages.toml file, merged with the default config. | ||
pub fn user_lang_config() -> Result<toml::Value, toml::de::Error> { | ||
let config = crate::local_config_dirs() | ||
.into_iter() | ||
.chain([crate::config_dir()].into_iter()) | ||
.map(|path| path.join("languages.toml")) | ||
.filter_map(|file| { | ||
std::fs::read(&file) | ||
.map(|config| toml::from_slice(&config)) | ||
.ok() | ||
}) | ||
.collect::<Result<Vec<_>, _>>()? | ||
.into_iter() | ||
.chain([default_lang_config()].into_iter()) | ||
.fold(toml::Value::Table(toml::value::Table::default()), |a, b| { | ||
crate::merge_toml_values(b, a) | ||
}); | ||
|
||
Ok(config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters