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

Allow composition of configs to avoid duplication #1513

Closed
eugenesvk opened this issue Jan 14, 2022 · 9 comments
Closed

Allow composition of configs to avoid duplication #1513

eugenesvk opened this issue Jan 14, 2022 · 9 comments
Labels
A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements

Comments

@eugenesvk
Copy link

Currently if you change a lot of normal mode keybinds (e.g., change the GoTo mode as [keys.normal."g"]), you'd have to copy these changes several times to other modes so they keep working there (e.g., as [keys.select."g"] since), which is rather cumbersome, especially when you tweak the configs.
The source code uses a nifty let mut select = normal.clone(); trick that allows only editing the keybinds that are different

Would you please allow a similar ease of composition for the user configs?

@eugenesvk eugenesvk added the C-enhancement Category: Improvements label Jan 14, 2022
@kirawi kirawi added A-helix-term Area: Helix term improvements A-keymap Area: Keymap and keybindings and removed A-helix-term Area: Helix term improvements labels Jan 14, 2022
@dead10ck
Copy link
Member

Duplicate of #1498

@eugenesvk
Copy link
Author

Not sure these is a duplicate. Let's assume I want to do the following:

  • I create a custom "minor mode" called key with a list of 10 commands
  • I want other minor modes (window mode, space mode, goto mode) to all have this key mode on k
  • I don't want Normal mode to have key have this mode, it's taken by something more useful

You suggestion in the other issue (which fits this one better) would be to allow me to set 'k'.isn to work in Major modes like Insert/Select/Normal (if I wanted to)
However, how would it allow making key work as an additional key in the minor modes?
The 'reusing a list of commands for dialogs' issue meant I could insert in each minor mode (default or custom) the following line (or something)

[keys.normal.'space']
'k' = 'my_Custom_Command_That_Is_Actually_A_Minor_Mode_Of_10_Commands_With_A_Name'
[keys.normal.'c-w']
'k' = 'my_Custom_Command_That_Is_Actually_A_Minor_Mode_Of_10_Commands_With_A_Name'
[keys.select.'space']
'k' = 'my_Custom_Command_That_Is_Actually_A_Minor_Mode_Of_10_Commands_With_A_Name'
[keys.select.'c-w']
'k' = 'my_Custom_Command_That_Is_Actually_A_Minor_Mode_Of_10_Commands_With_A_Name'
[keys.select.'x']              	# my custom minor mode
'a' = 'delete_char_forward'    	# builtin commands
'b' = 'delete_selection'       	# builtin commands
'c' = 'delete_selection_noyank'	# builtin commands
'k' = 'my_Custom_Command_That_Is_Actually_A_Minor_Mode_Of_10_Commands_With_A_Name'

and then if I replace those 10 commands in this minor key mode with something else, I wouldn't even have to change anything here

@dead10ck
Copy link
Member

Oh, so you mean like being able to define an alias for a list of commands. In the proposed format in the other issue, this would still be moderately better:

[keys]
"<Space>.ns" = { k = { ... } }
C-w.ns = { k = { ... } }
x.ns = { k = { ... } }

but yeah I see what you mean, it would help to be able to use an alias. Could be something like:

[alias]
my-alias = [ "a", "b", ... ]

[keys]
"<Space>.ns" = { k = "my-alias" }
C-w.ns = { k = "my-alias" }
x.ns = { k = "my-alias" }

@eugenesvk
Copy link
Author

would help to be able to use an alias

Yep, that would be great to have and is what I meant in the other issue: I set a list once and then refer to it via an alias

The solution to this issue would then allow you to set regular keys in various modes with a dot-mode .nsi notation (or something)

@eugenesvk
Copy link
Author

By the way, aliases might help solve this issue #1499 as well — I can map a command to call an alias it's defined in to make the dialog "sticky", but only for come commands

[my-space-mode-alias]
 "a" = "a_cmd"                	# dialog closes once this command is run
 "b" = "b_cmd"                	# same
 "c" = ["c_cmd",              	# dialog remains open after this one,
        "my-space-mode-alias"]	#    making this key "Sticky"

[keys]
'space'.ns = 'my-space-mode-alias'

@dead10ck
Copy link
Member

Very interesting idea

@pascalkuthe
Copy link
Member

Duplicate of #1752

@pascalkuthe pascalkuthe marked this as a duplicate of #1752 Apr 11, 2024
@pascalkuthe pascalkuthe closed this as not planned Won't fix, can't repro, duplicate, stale Apr 11, 2024
@eugenesvk
Copy link
Author

The other issues is about missing display labels, not internal composition references /aliases, so not a dupe

@pascalkuthe
Copy link
Member

yeah I lost track of the small differences between different issuse so I am going to keep this one closed. This will be adressed once we switch to a scheme based config (#10389)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

4 participants