From f6e46490fa6fba1a673ea90de5f27d56059ef154 Mon Sep 17 00:00:00 2001 From: Matthew Wilding Date: Thu, 3 Oct 2024 18:46:19 +0800 Subject: [PATCH 1/4] Add: Pick your own letters and prioritise, this way we can get homerow keys first, in my case aoeuhtns for dvorak Fix: Documentation had wrong default for shuffle_letters --- README.md | 25 ++++++++-------- doc/dashboard.txt | 31 +++++++++---------- lua/dashboard/init.lua | 2 ++ lua/dashboard/theme/hyper.lua | 56 ++++++++++++++--------------------- 4 files changed, 53 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 4e60852..41fe917 100644 --- a/README.md +++ b/README.md @@ -49,22 +49,23 @@ use { ## Options ```lua -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. +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 false, shortcut 'letter' will be randomize, set to false to have ordered letter +letter_list -- default is a-z, excluding j and k 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 +config = {}, -- config used for theme hide = { - statusline -- hide statusline default is true - tabline -- hide the tabline - winbar -- hide winbar + statusline -- hide statusline default is true + tabline -- hide the tabline + winbar -- hide winbar }, preview = { - command -- preview command - file_path -- preview file path - file_height -- preview file height - file_width -- preview file width + command -- preview command + file_path -- preview file path + file_height -- preview file height + file_width -- preview file width }, ``` diff --git a/doc/dashboard.txt b/doc/dashboard.txt index 5de7321..38193b4 100644 --- a/doc/dashboard.txt +++ b/doc/dashboard.txt @@ -13,7 +13,7 @@ Table of Contents *dashboard-table-of-contents* 6. LICENSE |dashboard-license| 7. Links |dashboard-links| Fancy and Blazing Fast start screen plugin of neovim ----------------------------------- ----------------------------------- - + ----------------------------------- ----------------------------------- @@ -65,22 +65,23 @@ Fancy and Blazing Fast start screen plugin of neovim -------------------------- OPTIONS *dashboard-configuration-options* >lua - 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 + theme = 'hyper' -- theme is doom and hyper default is hyper + disable_move -- default is false disable move keymap for hyper + shortcut_type -- shortcut type 'letter' or 'number' + shuffle_letter -- default is false, shortcut 'letter' will be randomize, set to false to have ordered letter + letter_list -- default is a-z, excluding j and k + 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 = { - statusline -- hide statusline default is true - tabline -- hide the tabline - winbar -- hide winbar + statusline -- hide statusline default is true + tabline -- hide the tabline + winbar -- hide winbar }, preview = { - command -- preview command - file_path -- preview file path - file_height -- preview file height - file_width -- preview file width + command -- preview command + file_path -- preview file path + file_height -- preview file height + file_width -- preview file width }, < @@ -282,7 +283,7 @@ MIT ============================================================================== 7. Links *dashboard-links* -1. *@RakerZh*: +1. *@RakerZh*: 2. **: https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white Generated by panvimdoc diff --git a/lua/dashboard/init.lua b/lua/dashboard/init.lua index 7286e6c..cf21b09 100644 --- a/lua/dashboard/init.lua +++ b/lua/dashboard/init.lua @@ -37,6 +37,7 @@ local function default_options() disable_move = false, shortcut_type = 'letter', shuffle_letter = false, + letter_list = "abcdefghilmnopqrstuvwxyz", buffer_name = 'Dashboard', change_to_vcs_root = false, config = { @@ -199,6 +200,7 @@ function db:load_theme(opts) confirm_key = opts.confirm_key or nil, shortcut_type = opts.shortcut_type, shuffle_letter = opts.shuffle_letter, + letter_list = opts.letter_list, change_to_vcs_root = opts.change_to_vcs_root, }) diff --git a/lua/dashboard/theme/hyper.lua b/lua/dashboard/theme/hyper.lua index 2da09be..1d12a74 100644 --- a/lua/dashboard/theme/hyper.lua +++ b/lua/dashboard/theme/hyper.lua @@ -214,54 +214,50 @@ local function shuffle_table(table) end local function letter_hotkey(config) - -- Reserve j, k keys to move up and down. - local list = { 106, 107 } + local used_keys = {} local shuffle = config.shuffle_letter + local letter_list = config.letter_list for _, item in pairs(config.shortcut or {}) do if item.key then - table.insert(list, item.key:byte()) + table.insert(used_keys, item.key:byte()) end end math.randomseed(os.time()) -- Create key table, fill it with unused characters. - local unused_keys = {} - -- a - z - for key = 97, 122 do - if not vim.tbl_contains(list, key) then - table.insert(unused_keys, key) + local function collect_unused_keys(uppercase) + local unused_keys = {} + for key in letter_list:gmatch(".") do + if uppercase then + key = key:upper() + end + key = key:byte() + if not vim.tbl_contains(used_keys, key) then + table.insert(unused_keys, key) + end end - end - - if shuffle then - shuffle_table(unused_keys) - end - - local unused_uppercase_keys = {} - -- A - Z - for key = 65, 90 do - if not vim.tbl_contains(list, key) then - table.insert(unused_uppercase_keys, key) + if shuffle then + shuffle_table(unused_keys) end + return unused_keys end - if shuffle then - shuffle_table(unused_uppercase_keys) - end + local unused_keys_lowercase = collect_unused_keys(false) + local unused_keys_uppercase = collect_unused_keys(true) -- Push shuffled uppercase keys after the lowercase ones - for _, key in pairs(unused_uppercase_keys) do - table.insert(unused_keys, key) + for _, key in pairs(unused_keys_uppercase) do + table.insert(unused_keys_lowercase, key) end local fallback_hotkey = 0 return function() - if #unused_keys ~= 0 then + if #unused_keys_lowercase ~= 0 then -- Pop an unused key to use it as a hotkey. - local key = table.remove(unused_keys, 1) + local key = table.remove(unused_keys_lowercase, 1) return string.char(key) else -- All keys are already used. Fallback to the number generation. @@ -271,14 +267,6 @@ local function letter_hotkey(config) end end -local function number_hotkey() - local start = 0 - return function() - start = start + 1 - return start - end -end - local function gen_hotkey(config) if config.shortcut_type == 'number' then return number_hotkey() From c945bab4decdd71bcda04002a2b50dad2b09d1e2 Mon Sep 17 00:00:00 2001 From: Matthew Wilding Date: Thu, 3 Oct 2024 18:55:53 +0800 Subject: [PATCH 2/4] Add back removed func --- .idea/.gitignore | 13 +++++++++++++ .idea/aws.xml | 17 +++++++++++++++++ .idea/discord.xml | 7 +++++++ .idea/encodings.xml | 4 ++++ .idea/indexLayout.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ doc/tags | 11 +++++++++++ lua/dashboard/theme/hyper.lua | 8 ++++++++ 8 files changed, 74 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/aws.xml create mode 100644 .idea/discord.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/indexLayout.xml create mode 100644 .idea/vcs.xml create mode 100644 doc/tags diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..da334e2 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/contentModel.xml +/projectSettingsUpdater.xml +/.idea.dashboard-nvim.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..d27816b --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..30bab2a --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/indexLayout.xml b/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/doc/tags b/doc/tags new file mode 100644 index 0000000..82fa10d --- /dev/null +++ b/doc/tags @@ -0,0 +1,11 @@ +dashboard-backers dashboard.txt /*dashboard-backers* +dashboard-configuration dashboard.txt /*dashboard-configuration* +dashboard-configuration-options dashboard.txt /*dashboard-configuration-options* +dashboard-configuration-theme-config dashboard.txt /*dashboard-configuration-theme-config* +dashboard-donate dashboard.txt /*dashboard-donate* +dashboard-feature dashboard.txt /*dashboard-feature* +dashboard-install dashboard.txt /*dashboard-install* +dashboard-license dashboard.txt /*dashboard-license* +dashboard-links dashboard.txt /*dashboard-links* +dashboard-table-of-contents dashboard.txt /*dashboard-table-of-contents* +dashboard.txt dashboard.txt /*dashboard.txt* diff --git a/lua/dashboard/theme/hyper.lua b/lua/dashboard/theme/hyper.lua index 1d12a74..3df456f 100644 --- a/lua/dashboard/theme/hyper.lua +++ b/lua/dashboard/theme/hyper.lua @@ -267,6 +267,14 @@ local function letter_hotkey(config) end end +local function number_hotkey() + local start = 0 + return function() + start = start + 1 + return start + end +end + local function gen_hotkey(config) if config.shortcut_type == 'number' then return number_hotkey() From afafe2bc6449f5a698c1b6ba834b8ac6ea05e2cf Mon Sep 17 00:00:00 2001 From: Matthew Wilding Date: Thu, 3 Oct 2024 18:56:32 +0800 Subject: [PATCH 3/4] Clean up .idea --- .idea/.gitignore | 13 ------------- .idea/aws.xml | 17 ----------------- .idea/discord.xml | 7 ------- .idea/encodings.xml | 4 ---- .idea/indexLayout.xml | 8 -------- .idea/vcs.xml | 6 ------ 6 files changed, 55 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/aws.xml delete mode 100644 .idea/discord.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/indexLayout.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index da334e2..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Rider ignored files -/modules.xml -/contentModel.xml -/projectSettingsUpdater.xml -/.idea.dashboard-nvim.iml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/aws.xml b/.idea/aws.xml deleted file mode 100644 index d27816b..0000000 --- a/.idea/aws.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml deleted file mode 100644 index 30bab2a..0000000 --- a/.idea/discord.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index df87cf9..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/indexLayout.xml b/.idea/indexLayout.xml deleted file mode 100644 index 7b08163..0000000 --- a/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 1bd9eda6944f8da8e68a65d22ea5077e01100afd Mon Sep 17 00:00:00 2001 From: Matthew Wilding Date: Thu, 3 Oct 2024 18:57:38 +0800 Subject: [PATCH 4/4] Clean tags --- doc/tags | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 doc/tags diff --git a/doc/tags b/doc/tags deleted file mode 100644 index 82fa10d..0000000 --- a/doc/tags +++ /dev/null @@ -1,11 +0,0 @@ -dashboard-backers dashboard.txt /*dashboard-backers* -dashboard-configuration dashboard.txt /*dashboard-configuration* -dashboard-configuration-options dashboard.txt /*dashboard-configuration-options* -dashboard-configuration-theme-config dashboard.txt /*dashboard-configuration-theme-config* -dashboard-donate dashboard.txt /*dashboard-donate* -dashboard-feature dashboard.txt /*dashboard-feature* -dashboard-install dashboard.txt /*dashboard-install* -dashboard-license dashboard.txt /*dashboard-license* -dashboard-links dashboard.txt /*dashboard-links* -dashboard-table-of-contents dashboard.txt /*dashboard-table-of-contents* -dashboard.txt dashboard.txt /*dashboard.txt*