-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Update settings at runtime #819
Conversation
/// Padding to keep between the edge of the screen and the cursor when scrolling. Defaults to 5. | ||
pub scrolloff: usize, | ||
scrolloff: Option<usize>, |
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 think we don't have to do this, we can just use a default for it in case it isn't there rather than being None
.
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 think being able to change all runtime settings is what we want later. But I don't think we need to keep track of whether values is set or not, we can just use the default and when it is set, override it with what the values was set.
But then if I have a "line-number = none" in my global config and I want to change it back to the default value: "line-number = absolute". |
Why do you want to detect what's changed? Line number none is a value by itself, which is not the default. If user set it to none obviously user wants it being none. |
Yes, my question was not about setting the value to |
I don't think we need to do that, we can just mention the defaults. That's how vim and kakoune did it IIRC, they just mentioned the default and you can set it back to that value yourself, not like |
If you really want that I can do it with the other PR. But from a user perspective, I find it quite bad personally. If I think “I want to set absolute number” I’m not thinking “I want the default settings back”... I don’t even know what is the default setting usually 😒 |
Regarding this, it should be shown in infobox like what kakoune did, since we can't expect user to remember. So I guess if we display it in the infobox it solves the issue? |
Sorry for the delay, I'm not completely satisfied with the amount of boilerplate code here (and needing to subtype config into complete/incomplete). Trying to think if there's a better way to accomplish this. I think I agree with @pickfire in that it's not too important to us to track which values are set and which fall back to the defaults. Rather, I'd keep a single config object (like we have now, that merges built-in defaults with the config file), then
Precisely. If I change a value I can always manually change it back. |
Closing in favour of #798 |
Hello @pickfire, I was not happy with #798, and I was thinking about your comments, and I thought something was wrong with my first implementation.
Mainly I didn’t like this solution. I feel like matching on a string will be a kind of technical debt. Everytime we’ll update the
Config
structure we’ll need to remember to update this match statement in a totally random place in the code.And then, while looking at what
kakoune
did, if we want something like them we’ll need to store “parts” of the config in multiple place.For example, we could have our “base config” as we have currently. And then each
window
andbuffer
could have its own “incomplete” config.And then to get the “real” config you would:
To make this “type-safe” I didn’t find any other solution than creating a “typed fsm” (I don’t know if it’s the term) where a config can either be
Complete
orIncomplete
.If the config is
Complete
, when we access one field it returns the expected value as before. If it’sIncomplete
it returns anOption
.The code is a little bit raw right now; maybe we could create a macro or something like that.
But before spending too much time on it I would like to hear what you think of this idea. Is it something we want to merge?
It changes a lot of code, but I think it’ll allow us to do some great things later in a type-safe and fast manners!