kamiyaa / joshuto

ranger-like terminal file manager written in Rust
https://crates.io/crates/joshuto
GNU Lesser General Public License v3.0
3.47k stars 154 forks source link

mimetype.toml and keymap.toml should allow overrides in user config #148

Open sushi-shi opened 2 years ago

sushi-shi commented 2 years ago

The only thing I want to flip from defaults in mimetype is

mapcommand = [
    { keys = [ "/" ], command = ":search_inc " },
]

However I cannot specify only this command as everything else stops working. keymap seems to suffer from the same thing.

I'll have a look at it a bit later, just don't want to forget about it in the meantime.

sushi-shi commented 2 years ago

Also formatting inside toml files seems a bit strange, we can look at default formatters for those, just so everything is consistent.

sushi-shi commented 2 years ago

keymap is also not picked up by default when absent from user config.

kamiyaa commented 2 years ago

keymap is also not picked up by default when absent from user config.

This should be pretty straightforward to implement and I can do it.

Also formatting inside toml files seems a bit strange, we can look at default formatters for those, just so everything is consistent.

Yep, that sounds good to me.

The only thing I want to flip from defaults in mimetype is

mapcommand = [
  { keys = [ "/" ], command = ":search_inc " },
]

However I cannot specify only this command as everything else stops working. keymap seems to suffer from the same thing.

I'll have a look at it a bit later, just don't want to forget about it in the meantime.

Yes, this is a bit of a problem. I wanted it like this because it prevents issues where users want keys to be unmapped.

sushi-shi commented 2 years ago

Yes, this is a bit of a problem. I wanted it like this because it prevents issues where users want keys to be unmapped.

We can add another option in configuration to make unmapping explicit. Something like this (if it is allowed in toml, I skimmed their documentation, but still not sure).

mapcommand = [
    { keys = [ "/" ], no_command },
    { keys = [ "/" ], command = "" }, // or like this
]

Yep, that sounds good to me.

This formatter looks promising, though I'd rather we still maintained alignment. https://taplo.tamasfe.dev/

This should be pretty straightforward to implement and I can do it.

Thank you! I'll have a look at other things a bit later.

Also quite a few fields in structs have names starting with a _. Why? In Rust you can define methods with field names.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7d508a8a2d9871deb005daa7d67c6102

kamiyaa commented 2 years ago

keymap is also not picked up by default when absent from user config.

This should be pretty straightforward to implement and I can do it.

Actually, I think this is implemented already? :thinking:

https://github.com/kamiyaa/joshuto/blob/main/src/config/keymap/keymapping.rs#L40

https://github.com/kamiyaa/joshuto/blob/main/src/config/keymap/keymapping.rs#L102

kamiyaa commented 2 years ago

Also quite a few fields in structs have names starting with a _. Why? In Rust you can define methods with field names.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7d508a8a2d9871deb005daa7d67c6102

Oh, I did not know that :eyes: Thanks!