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

feat: Make it possible to keybind TypableCommands #1169

Merged
merged 3 commits into from
Dec 4, 2021

Conversation

Nehliin
Copy link
Contributor

@Nehliin Nehliin commented Nov 25, 2021

Fixes: #852

This makes it possible to add keymaps for TypableCommands (including aliases + commands with arguments) in your config.toml like the following example:

[keys.normal]
"space" = { "t" = ":earlier 5 sec", "y" = ":theme default"}
"f"  = ":format"
"C-s" = ":w"
# Previously mapped "static commands"
"C-l" = "jump_view_right"
"C-h" = "jump_view_left"
"C-j" = "jump_view_down"
"C-k" = "jump_view_up"

This solution is a lot less hacky than my previous pr and makes it possible to map all current and future TypableCommands. I decided to not go for the [ .. ] surround for command arguments because it would just be more of a hassle to parse with little benefit for users imo. Arguments are passed by space separating them after the initial command instead.

Update: aliases are supported as well so updated the example

@Nehliin Nehliin force-pushed the dynamic-commands branch 2 times, most recently from 113cb85 to c8862c2 Compare November 25, 2021 21:27
helix-term/src/commands.rs Outdated Show resolved Hide resolved
helix-term/src/commands.rs Outdated Show resolved Hide resolved
helix-term/src/commands.rs Outdated Show resolved Hide resolved
helix-term/src/commands.rs Outdated Show resolved Hide resolved
helix-term/src/commands.rs Outdated Show resolved Hide resolved
@Nehliin
Copy link
Contributor Author

Nehliin commented Nov 28, 2021

Rebased updated PartialEq implementation and reverted to compositor::Context now. Also I really want to break out Typable, Mappable and Static commands to their own files. At least the long hard coded command lists because the current command file is >5000 loc and a bit annoying to work with. But I can do that in a follow up pr.

@archseer
Copy link
Member

Yeah, I've been wanting to do this for a while but it will break pending PRs in the queue. Let's wait until I manage to catch up with the merges.

@Nehliin
Copy link
Contributor Author

Nehliin commented Nov 29, 2021

@archseer Sure, like I said I don't want to do that in this pr since that would make it quite huge. Better to do it in a separate pr imo

Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

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

LGTM but I'd like to get an approval from @sudormrfbin too :)

Copy link
Member

@sudormrfbin sudormrfbin left a comment

Choose a reason for hiding this comment

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

LGTM ! Great work @Nehliin 🎉

@sudormrfbin sudormrfbin merged commit a06871a into helix-editor:master Dec 4, 2021
@Nehliin Nehliin deleted the dynamic-commands branch December 4, 2021 15:33
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.

Keymap for :format or other TypableCommands
3 participants