Skip to content

Add kitty protocol config to nushell - #10540

Merged
sholderbach merged 6 commits into
nushell:mainfrom
Abdillah:feature/kittyproto
Sep 29, 2023
Merged

Add kitty protocol config to nushell#10540
sholderbach merged 6 commits into
nushell:mainfrom
Abdillah:feature/kittyproto

Conversation

@Abdillah

Copy link
Copy Markdown
Contributor

This PR should close #9733.

Description

Support keyboard enhancement protocol as implemented by Kitty console, hence Kitty protocol.

This PR enables Nushell to use keybinding that is not available before, such as Ctrl+i (that alias to Tab) or Ctrl+e (that alias to Esc, likely I mistaken). After this PR merged and you set use_kitty_protocol enabled, if your console app support Kitty protocol (WezTerm, Kitty, etc.) you will be able to set more fine-grained keybinding.

For Colemak users, this feature is a blessing, because some Ctrl+[hjkl] that previously unmap-able to Ctlr+[hnei] now it is.

User-Facing Changes

This adds use_kitty_protocol config which defaults to false. When set to true, it enables kitty protocol on the line editor when supported, or else it warns.

Tests + Formatting

  • cargo fmt --all -- --check to check standard code formatting (cargo fmt --all applies these changes)
  • cargo clippy --workspace -- -D warnings -D clippy::unwrap_used to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass (on Windows make sure to enable developer mode)
    It produces an error. I don't think this is my doing since the current main also suffers this error in my local.
    failures:
    
    ---- shell::run_in_login_mode stdout ----
    thread 'shell::run_in_login_mode' panicked at 'assertion failed: child_output.stderr.is_empty()', tests/shell/mod.rs:243:5
    
    
    failures:
        shell::run_in_login_mode
    
    test result: FAILED. 485 passed; 1 failed; 20 ignored; 0 measured; 0 filtered out; finished in 49.96s
    
  • cargo run -- -c "use std testing; testing run-tests --path crates/nu-std" to run the tests for the standard library

@fdncred

fdncred commented Sep 28, 2023

Copy link
Copy Markdown
Contributor

If we move forward with this, there would need to be a default and that default would need to be set in the default_config.nu file in this repo.

@Abdillah

Abdillah commented Sep 28, 2023

Copy link
Copy Markdown
Contributor Author

I see, I missed that.

The default would be false right?

@sholderbach sholderbach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks for the followup, this looks good to me. I don't observe any breakage in non-kitty-compatible terminals.

One small thing to fix and we should be good to go

Comment thread crates/nu-cli/src/commands/keybindings_listen.rs Outdated
@sholderbach
sholderbach merged commit 7ad4c67 into nushell:main Sep 29, 2023
@Abdillah
Abdillah deleted the feature/kittyproto branch September 30, 2023 01:07
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
# Description

Support keyboard enhancement protocol as implemented by Kitty console,
hence Kitty protocol.

This PR enables Nushell to use keybinding that is not available before,
such as Ctrl+i (that alias to Tab) or Ctrl+e (that alias to Esc, likely
I mistaken). After this PR merged and you set `use_kitty_protocol`
enabled, if your console app support Kitty protocol (WezTerm, Kitty,
etc.) you will be able to set more fine-grained keybinding.

For Colemak users, this feature is a blessing, because some Ctrl+[hjkl]
that previously unmap-able to Ctlr+[hnei] now it is.

# User-Facing Changes

This adds `use_kitty_protocol` config which defaults to false. When set
to `true`, it enables kitty protocol on the line editor when supported,
or else it warns.


---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
sholderbach pushed a commit that referenced this pull request Sep 24, 2024
# Description
hi hi, this makes the parsing of modifier key combos in config more
general, and adds support for additional kitty keyboard protocol
modifiers. It seems that support for [kitty
keys](https://sw.kovidgoyal.net/kitty/keyboard-protocol) had already
been added to nushell in #10540,
and this was the only missing piece to making them available in
keybindings.

# User-Facing Changes
- keybindings in config can include the super, hyper and meta modifiers
(e.g. `modifier: super`, `modifier: shift_super`, etc.), and these
modifiers will work in supporting terminals (kitty, foot, wezterm,
alacritty...)
- all permutations of snake_cased modifier combinations now behave
equivalently for the purpose of describing keybindings in config (e.g.
`control_alt_shift` was previously supported where `shift_control_alt`
was a config error — now they're the same)

# Tests
None of this looks to be tested at the moment. I only found a smoke test
under the nu-cli crate, and I couldn't break tests elsewhere by stuffing
around with modifier handling. Works on my machine, though! ✨🌈
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

Successfully merging this pull request may close these issues.

Support Kitty keyboard enhancement protocol

3 participants