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

Option for fixed/alphabetical shortcut ordering for hyper theme #464

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading