Skip to content

Commit 8d06f36

Browse files
authored
Option for fixed/alphabetical shortcut ordering for hyper theme (#464)
* feat(hyper): add option to use ordered `shortcut` * docs(readme): update new option in README.md * style(stylua): fix linter error
1 parent 69a4c93 commit 8d06f36

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ use {
5252
theme = 'hyper' -- theme is doom and hyper default is hyper
5353
disable_move -- default is false disable move keymap for hyper
5454
shortcut_type -- shorcut type 'letter' or 'number'
55+
shuffle_letter -- default is true, shortcut 'letter' will be randomize, set to false to have ordered letter.
5556
change_to_vcs_root -- default is false,for open file in hyper mru. it will change to the root of vcs
5657
config = {}, -- config used for theme
5758
hide = {

lua/dashboard/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ local function default_options()
3636
theme = 'hyper',
3737
disable_move = false,
3838
shortcut_type = 'letter',
39+
shuffle_letter = false,
3940
buffer_name = 'Dashboard',
4041
change_to_vcs_root = false,
4142
config = {
@@ -190,6 +191,7 @@ function db:load_theme(opts)
190191
winid = self.winid,
191192
confirm_key = opts.confirm_key or nil,
192193
shortcut_type = opts.shortcut_type,
194+
shuffle_letter = opts.shuffle_letter,
193195
change_to_vcs_root = opts.change_to_vcs_root,
194196
})
195197

lua/dashboard/theme/hyper.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ end
216216
local function letter_hotkey(config)
217217
-- Reserve j, k keys to move up and down.
218218
local list = { 106, 107 }
219+
local shuffle = config.shuffle_letter
219220

220221
for _, item in pairs(config.shortcut or {}) do
221222
if item.key then
@@ -234,7 +235,9 @@ local function letter_hotkey(config)
234235
end
235236
end
236237

237-
shuffle_table(unused_keys)
238+
if shuffle then
239+
shuffle_table(unused_keys)
240+
end
238241

239242
local unused_uppercase_keys = {}
240243
-- A - Z
@@ -244,7 +247,9 @@ local function letter_hotkey(config)
244247
end
245248
end
246249

247-
shuffle_table(unused_uppercase_keys)
250+
if shuffle then
251+
shuffle_table(unused_uppercase_keys)
252+
end
248253

249254
-- Push shuffled uppercase keys after the lowercase ones
250255
for _, key in pairs(unused_uppercase_keys) do

0 commit comments

Comments
 (0)