-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 [docs] Add example for nested leader keys
- Loading branch information
Showing
13 changed files
with
144 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/modifier-keys/caps_lock-to-hyper.js → examples/modifier-keys/caps_lock-to-hyper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { | ||
KeyAlias, | ||
LetterKeyCode, | ||
mapSimultaneous, | ||
ModifierKeyAlias, | ||
modifierKeyAliases, | ||
MultiModifierAlias, | ||
multiModifierAliases, | ||
rule, | ||
toRemoveNotificationMessage, | ||
} from '../../src' | ||
|
||
let rules = [ | ||
rule('duo-modifiers').manipulators( | ||
duoModifiers({ | ||
'⌘': ['fd', 'jk'], // ⌘ first as used the most | ||
'⌃': ['fs', 'jl'], // ⌃ second as Vim uses it | ||
'⌥': ['fa', 'j;'], // ⌥ last as used the least | ||
|
||
'⇧': ['ds', 'kl'], | ||
|
||
'⌘⇧': ['gd', 'hk'], | ||
'⌃⇧': ['gs', 'hl'], | ||
'⌥⇧': ['ga', 'h;'], | ||
|
||
'⌘⌥': ['vc', 'm,'], | ||
'⌘⌃': ['vx', 'm.'], | ||
'⌥⌃': ['cx', ',.'], | ||
|
||
'⌘⌥⌃': ['vz', 'm/'], | ||
}), | ||
), | ||
] | ||
|
||
function duoModifiers( | ||
v: Partial< | ||
Record< | ||
'⌘' | '⌥' | '⌃' | '⇧' | MultiModifierAlias, | ||
`${LetterKeyCode | KeyAlias}${LetterKeyCode | KeyAlias}`[] | ||
> | ||
>, | ||
) { | ||
let result = [] | ||
|
||
for (let [m, k] of Object.entries(v)) { | ||
for (let keys of k) { | ||
let id = k + m | ||
let [firstMod, ...restMods] = ( | ||
m in modifierKeyAliases | ||
? [modifierKeyAliases[m as ModifierKeyAlias]] | ||
: multiModifierAliases[m as MultiModifierAlias] | ||
) as Array<'command' | 'control' | 'option' | 'shift'> | ||
|
||
let to_after_key_up = [toRemoveNotificationMessage(id)] | ||
result.push( | ||
mapSimultaneous(keys.split('') as (LetterKeyCode | KeyAlias)[], { | ||
to_after_key_up, | ||
}) | ||
.toNotificationMessage(id, m) // Must go first or to() doesn't work | ||
.to(`left_${firstMod}`, restMods), | ||
) | ||
} | ||
} | ||
|
||
return result | ||
} |
2 changes: 1 addition & 1 deletion
2
...les/os-functionality/launch-apps-layer.js → ...les/os-functionality/launch-apps-layer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../os-functionality/launch-apps-modifier.js → .../os-functionality/launch-apps-modifier.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/text-input/symbols.js → examples/text-input/symbols.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"label": "Vim" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Leader key | ||
--- | ||
|
||
To nest leader keys, use variables on [leaderMode()](/rules/leader-mode). | ||
|
||
- `leader` `o` `f`: Open Finder | ||
- `leader` `r` `e`: Raycast Emoji Picker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
hyperLayer, | ||
ifVar, | ||
map, | ||
toUnsetVar, | ||
withCondition, | ||
withMapper, | ||
} from '../../src' | ||
|
||
let escapeLeader = ['__layer', 'leader', 'leader--'].map(toUnsetVar) | ||
let raycastEmoji = 'emoji-symbols/search-emoji-symbols' | ||
|
||
let rules = [ | ||
hyperLayer('l', 'leader') | ||
.leaderMode({ sticky: true, escape: [] }) | ||
.manipulators([ | ||
map('escape').to(escapeLeader), | ||
|
||
map('o').toVar('leader--', 'o'), // Open | ||
withCondition(ifVar('leader--', 'o'))([ | ||
withMapper([ | ||
map('f').toApp('Finder'), // Open Finder | ||
])((x) => x.to(escapeLeader)), | ||
]), | ||
|
||
map('r').toVar('leader--', 'r'), // Raycast | ||
withCondition(ifVar('leader--', 'r'))([ | ||
withMapper([ | ||
map('e').to$(`open raycast://extensions/raycast/${raycastEmoji}`), | ||
])((x) => x.to(escapeLeader)), | ||
]), | ||
]), | ||
] |