-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support for local language configuration #1249
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7e9a172
add local configuration
kirawi 4ffe169
move config loading to Application::new
kirawi a09d32c
resolve merge conflicts
kirawi 34f8420
merge upstream
kirawi 4485026
simplify find_root_impl
kirawi bdf4914
merge with upstream
kirawi dc781a4
Merge branch 'master' of github.com:helix-editor/helix into local
kirawi faa9bde
merge with upstream
kirawi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry I'm kind of late to the party here. Thanks for the change, @kirawi, this will be super useful!
But this particular part of the change actually presents a problem. I'm working on an integration testing branch, and this change makes it so that you can't pass in a pre-parsed Config object. This was very useful for testing, as it's super easy to just make the struct literal you want to describe the config option you want to test. Now it seems that the config can only come from a toml file. Could we please move this logic back into main?