Skip to content

Commit

Permalink
Option for fixed/alphabetical shortcut ordering for hyper theme (#…
Browse files Browse the repository at this point in the history
…464)

* feat(hyper): add option to use ordered `shortcut`

* docs(readme): update new option in README.md

* style(stylua): fix linter error
  • Loading branch information
kuntau authored Jul 1, 2024
1 parent 69a4c93 commit 8d06f36
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ use {
theme = 'hyper' -- theme is doom and hyper default is hyper
disable_move -- default is false disable move keymap for hyper
shortcut_type -- shorcut type 'letter' or 'number'
shuffle_letter -- default is true, shortcut 'letter' will be randomize, set to false to have ordered letter.
change_to_vcs_root -- default is false,for open file in hyper mru. it will change to the root of vcs
config = {}, -- config used for theme
hide = {
Expand Down
2 changes: 2 additions & 0 deletions lua/dashboard/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ local function default_options()
theme = 'hyper',
disable_move = false,
shortcut_type = 'letter',
shuffle_letter = false,
buffer_name = 'Dashboard',
change_to_vcs_root = false,
config = {
Expand Down Expand Up @@ -190,6 +191,7 @@ function db:load_theme(opts)
winid = self.winid,
confirm_key = opts.confirm_key or nil,
shortcut_type = opts.shortcut_type,
shuffle_letter = opts.shuffle_letter,
change_to_vcs_root = opts.change_to_vcs_root,
})

Expand Down
9 changes: 7 additions & 2 deletions lua/dashboard/theme/hyper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ end
local function letter_hotkey(config)
-- Reserve j, k keys to move up and down.
local list = { 106, 107 }
local shuffle = config.shuffle_letter

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

shuffle_table(unused_keys)
if shuffle then
shuffle_table(unused_keys)
end

local unused_uppercase_keys = {}
-- A - Z
Expand All @@ -244,7 +247,9 @@ local function letter_hotkey(config)
end
end

shuffle_table(unused_uppercase_keys)
if shuffle then
shuffle_table(unused_uppercase_keys)
end

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

0 comments on commit 8d06f36

Please sign in to comment.