-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Improve config defaults #47
Conversation
Hey @maximbaz This PR should support the |
6132360
to
a92da4e
Compare
Here's what I'm trying, doesn't seem to be working or it's not working as I was imagining 🙂
Does this work for you, give you different icons than standard? |
eb68c7f
to
f14cf02
Compare
Actually |
Then as of now |
f14cf02
to
6e60477
Compare
Done, you can try version: v0.3.13
node_types:
directory:
meta:
icon: "d"
file:
meta:
icon: "f"
symlink:
meta:
icon: "s"
style:
fg: Red |
@maximbaz If possible, also test the key bindings. |
Example: modes:
builtin:
default:
name: default
key_bindings:
on_key:
".":
help: "foo action"
messages:
- LogInfo: foo |
Yeah, it works! And I think this approach is really cool! I'd like to add to the topic of versioning configs:
I think it will be more ideal if we don't bug user if there is literally nothing for them to change, but we should definitely bug users if their config doesn't apply cleanly. In other words, if something changed in the config, it's either change of default that I didn't override (in which case yay, I dont need to do anything), or it's a change in default that I did override anyway (in which case still I dont need to do anything, I already configured my preferred option), or it's a "breaking" change in which case my config doesn't apply anymore - in this case, I want to be notified 🙂 What do you think? |
The problem with that approach is detecting what the user has overwritten. Even though detecting changes in the config format might be somehow possible, it'll be impossible to detect changes in the commands. e.g.
Users will never know if I change something in |
Also, this PR will be a major (comparatively) change. So, you need to update from |
However... I think I can implement a logic something like match config_version {
"0.3.13" => Compatible,
"0.3.13" => Compatible,
_ => InCompatible,
} And users will only see errors/log when they need to. |
Good example, and yes, we could try this! By the way, have you considered following https://semver.org? I think many users would be familiar that if it's a change in major version, breaking changes are expected, while minor/patch version changes would indicate that their configs will work for sure? |
I'm following something similar but a somewhat simpler approach in my mind. However, until we're |
Try this: --- a/src/config.rs
+++ b/src/config.rs
@@ -474,6 +474,7 @@ impl ModesConfig {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
pub struct Config {
#[serde(default = "default_config::version")]
pub version: String, It crashes in runtime, maybe we could make this into an error log instead? This would be very helpful I think... |
838d7da
to
3066dcd
Compare
Thanks to anyhow, we already have a
|
- Rename `custom` field for node metadata to `meta`. - Move `icon` to `meta.icon`. - Rename `normal_ui` to `default_ui`. - Rename `filetypes` to `node_types`. - Split `modes` into `modes.builtin` and `modes.custom`. - Add the missing `create file` mode. - Rename `focused_ui` to `focus_ui`. - Make `general.table.header` non-nullable. - Add support for incremental configuration updates. Ref: #45
49d1b34
to
ce5cd3a
Compare
Done, @maximbaz please review when you get time. |
From this version, xplr won't annoy the users to visit the upgrade guide when there is no need. Also, users will only get upgrade related notification when it is there is one.
ce5cd3a
to
a63646c
Compare
410a45b
to
a1b7f4f
Compare
This is really awesome, I think it's a great improvement! Regarding the error, at first I was thinking maybe preventing the app from starting is too harsh and we should let the app open (and simply ignore that unknown part of the config), and show error in the bottom part of xplr UI (as log message). But then I saw we prevent the startup when config version changed anyway, so maybe it's fine 🙂 |
Also, - Add key binding `~` to go to homedir. - Add customizable cursor and prompts. - Improve the help menus.
Done and released https://github.com/sayanarijit/xplr/wiki/Upgrade-Guide#v0313---v041. |
Hey @sayanarijit, just wanted to follow-up on this, it generally works well but I found two cases to consider:
general:
default_ui:
prefix: " "
suffix: " "
focus_ui:
prefix: "▸[ "
suffix: " ]"
style:
fg: Cyan
selection_ui:
prefix: " { "
suffix: " }"
|
custom
field for node metadata tometa
.icon
tometa.icon
.normal_ui
todefault_ui
.filetypes
tonode_types
.modes
intomodes.builtin
andmodes.custom
.create file
mode.focused_ui
tofocus_ui
.general.table.header
non-nullable.~
to go to homedir.Ref: #45