Skip to content
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

[NEW FEATURE] Custom keybindings #47

Open
AlisCode opened this issue Aug 21, 2024 · 3 comments
Open

[NEW FEATURE] Custom keybindings #47

AlisCode opened this issue Aug 21, 2024 · 3 comments

Comments

@AlisCode
Copy link

AlisCode commented Aug 21, 2024

First of all: Hi, great work on this tool! I'd like to start using it by integrating it into my neovim config. This is an awesome effort, thanks for the hard work.

Is your feature request related to a problem? Please describe.
I'm a bit frustrated by the lack of configuration for keybindings. Namely :

  • Using tab to swap between panels isn't really part of my workflow. I'd prefer vim-style bindings such as using H and L to swap between panels for example.
  • Using q to quit the app fits my workflow, but I got frustrated when I saw the help panel and I tried to discard it with q, which .. quit the app. Wish I could change that myself.

This is just me though, and I'm sure other people would love to customize the tool how they see fit. A follow-up to this issue is probably the ability to customize the colors of the app (the white text on pink background on the help panel in my terminal is .. very hard to read)

Describe the solution you'd like
Ideally the user would be able to have a keybindings file stored wherever deemed relevant (e.g. $HOME/.config/oxker/keybindings.ron).

Implementation-wise :

  • A Config struct, that would contain a field keybindings: KeybindingsConfig should be constructed
  • The config needs to be injected and stored in the InputHandler
  • Documentation should be written to empower the user to write their own bindings

Regarding the format of the config file, there's a metric ton of alternatives, including :

  • TOML, pretty standard for Rust
  • JSON, pretty standard
  • YAML, pretty standard for Docker
  • RON, a bit foreign to pretty much everyone, but offers probably the nicest DX of all described alternatives if that matters to you

I really like gitui's documentation and technical choice (RON), but I fully acknowledge that it might not be the most welcoming choice, especially for non-Rust folks. Nothing more frustrating than learning about a new tool and seeing a config file with an extension that you've never seen before.

All in all, I think RON or TOML would be great choices. Let me know what you think.

Describe alternatives you've considered
I described alternatives for config languages above.
For larger customization purposes, programs such as neovim allow the user to customize everything with Lua, but this is because the customization goes waaay beyond the scope of keybindings.

Additional context
Looks like input_handler/mod.rs contains the list of hardcoded keybindings.
Some functions may need to be renamed, e.g. s_key, enter_key, tab_key and the likes.

@mrjackwills
Copy link
Owner

Yeah that sounds useful, I think the format of the config file could be a sticking point. I'd always edge towards JSON, for ease of use, even though the format itself always causes me pain, but that gitui documentation is interesting and informative.

@jolsen-mitsu
Copy link

JSON isn't too terrible, especially if you support JSONC, namely being able to comment lines out with the "//" prefix and allowing unnecessary trailing commas that would normally cause JSON parsers to choke.

YAML is also easy and can be a little less verbose than JSON, but some of the nomenclature can be tricky.

My personal vote would be for JSON/JSONC.

@andrew-manger
Copy link

As primarily a docker user, YAML or JSON are preferred for me!

mrjackwills added a commit that referenced this issue Feb 16, 2025
Enable use of a config file, with custom keymap and custom colours
mrjackwills added a commit that referenced this issue Feb 16, 2025
Enable use of a config file, with custom keymap and custom colours
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants