-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat: add configuration file support #70
base: main
Are you sure you want to change the base?
Conversation
No attributes yet though
- Updated test assertions to reflect the changes in active_item_style
- Added `env_logger` for enhanced logging capabilities. - Integrated `shellexpand` to handle tilde expansion in config paths. - Updated `ConfigContentStyle` to use simplified field names. - Ensured unknown fields in config files are denied. - Modified tests to reflect changes in `ConfigContentStyle`.
Added support for custom key events and focus prefixes in the configuration. This includes new fields in the Config and ConfigFile structs, as well as updates to the merge function and related tests. The changes enhance the flexibility and customizability of the editor.
I'd like to get a general temperature check on pursuing this path @ynqa |
Added spin_duration field to Config and ConfigFile structs. Updated merge function to handle spin_duration. Set default spin_duration to 300ms. Removed redundant spin_duration initialization in main.
Added new style options to Config and ConfigFile structs, including prefix_style, active_char_style, inactive_char_style, curly_brackets_style, square_brackets_style, key_style, string_value_style, number_value_style, boolean_value_style, and null_value_style. Updated merge function and default implementation to handle these new styles.
Removed unused dependencies `env_logger`, `log`, and `humantime` from Cargo.toml and Cargo.lock. Cleaned up related imports and initialization code in main.rs.
long = "write-default-config", | ||
help = "Writes the default configuration to the specified file and exits." | ||
)] | ||
pub write_default_config: bool, |
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 want to create the config file at the time of the first execution.
src/main.rs
Outdated
long_help = " | ||
Specifies the path to the configuration file. | ||
", | ||
default_value = "~/.config/jnv/config.toml", |
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.
How about using directories-rs for default? I want to manage the optimal directory for each platform.
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.
Easy enough
@lanej Thank you for your contribution. I’m sorry for the delayed review, and I’ve left a few comments. |
default_value = "~/.config/jnv/config.toml", | ||
value_parser = |x: &str| Ok::<String, std::convert::Infallible>(shellexpand::tilde(x).into_owned()), | ||
)] | ||
pub config_file: String, |
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’d like to place an example of the actual configuration file somewhere (in examples/
?).
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.
Good idea
- Bump versions for various dependencies in Cargo.lock - Add `dirs` crate to Cargo.toml - Remove `shellexpand` crate from Cargo.toml
Introduces a configuration file support for the project, following the XDG Base Directory Specification. The configuration file allows users to customize various settings, including keybindings and color schemes. This update enhances the flexibility and user experience of the application by allowing greater customization
according to individual preferences.
Key Features 🔑
~/.config/jnv/config.toml
. This allows users to define custom configurations outside of the codebase.Changes Summary 📋
• Added a new module
config.rs
to handle loading and parsing of the configuration file.• Refactored the
main.rs
to incorporate configuration loading logic and adjusted the initialization of various components to use the loaded configurations.• Expanded
editor.rs
to utilize keybindings from the configuration file.• Adjusted
prompt.rs
to align with the changes in the configuration handling structure.• Added default configuration logic to ensure application functionality in the absence of a custom configuration file.
References 📖
Closes #23 by implementing a system for customizable configurations as discussed.
Thoughts 🧠
JQ_COLORS
environment variable for color customization if not specified in the configuration file.TODO 🗒️
~/.config
directoryexamples/
and some sample configurations.