zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
25.22k stars 1.18k forks source link

Disable micro auto formatting bindings.json when adding new bindings #3302

Open Neko-Box-Coder opened 6 months ago

Neko-Box-Coder commented 6 months ago

Description of the problem or steps to reproduce

micro keeps auto formatting bindings.json, when there's a new binding needs to be added to the json (either from user or plugin). Resulting it removing all the comments and reordering everything. Making it difficult to keep track of modified keys.

Specifications

Commit hash: 91765082 OS: Linux Terminal: WezTerm

Neko-Box-Coder commented 6 months ago

So this happens when whatever is trying to bind/unbind a key, whether it is from the user or a plugin. The same goes for settings. I guess it's alright it is coming from the user (using bind) but not quite so if it is from the plugin.

Having my keybindings/settings formatting and comments get removed completely is quite annoying and discouraging.

I think we should just do a string append ourselves instead. This should be relatively achievable. So here are the places where the jsons get write to so that I or someone can come back to later:

https://github.com/zyedidia/micro/blob/917650826a9da1b8d7223d2e3b9b1ad5ac845aa2/internal/config/settings.go#L293-L294

https://github.com/zyedidia/micro/blob/917650826a9da1b8d7223d2e3b9b1ad5ac845aa2/internal/config/settings.go#L315-L316

https://github.com/zyedidia/micro/blob/917650826a9da1b8d7223d2e3b9b1ad5ac845aa2/internal/action/bindings.go#L376-L376

https://github.com/zyedidia/micro/blob/917650826a9da1b8d7223d2e3b9b1ad5ac845aa2/internal/action/bindings.go#L319-L320

dev-nicolaos commented 3 months ago

Related: https://github.com/zyedidia/micro/issues/2194