From dbd92f03a9ee71438c0035d007a81ef3df4a1f8c Mon Sep 17 00:00:00 2001 From: Mihails Mozajevs Date: Thu, 4 Jan 2024 16:01:59 +0000 Subject: [PATCH 1/2] feat: add colemak/colemak-dh support Co-authored-by: tris203 --- README.md | 25 +++++++++++++-- lua/hawtkeys/init.lua | 2 -- lua/hawtkeys/keyboards.lua | 5 +++ lua/hawtkeys/keyboards/colemak-dh.lua | 44 +++++++++++++++++++++++++++ lua/hawtkeys/keyboards/colemak.lua | 43 ++++++++++++++++++++++++++ lua/hawtkeys/keyboards/qwerty.lua | 5 +++ 6 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 lua/hawtkeys/keyboards/colemak-dh.lua create mode 100644 lua/hawtkeys/keyboards/colemak.lua diff --git a/README.md b/README.md index 297bbc9..252a40a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ It takes into consideration keyboard layout, easy-to-press combinations and memorable phrases, and excludes already mapped combinations to provide you with suggested keys for your commands ## 📦 Installation + Installation instructions to follow, but as usual with package managers ```lua @@ -12,6 +13,7 @@ return { config = true, } ``` + ## ❔Usage ### Searching New Keymaps @@ -42,8 +44,8 @@ HawtkeysDupes It will show potential duplicate keymaps, where you have accidentally set the same key for two different things. This can be useful for tracking down issues with plugins not functioning correctly - ## ⚙️ Config + ```lua return { leader = " ", -- the key you want to use as the leader, default is space @@ -87,7 +89,24 @@ return { }, } ``` -The default config will get all keymaps using the ```vim.api.nvim_set_keymap``` and ```vim.keymap.set```. + +The default config will get all keymaps using the `vim.api.nvim_set_keymap` and `vim.keymap.set`. + +## ⌨️ Keyboard Layouts + +Currently supported keyboard layouts are: + +- qwerty +- colemak +- colemak-dh + +We would welcome any PRs to add keyboard layouts. + +Keyboard Contributors: + +- [@delinx](https://github.com/delinx) [^1] + +[^1]: colemak / colemak-dh ## ✍️ Contributing @@ -108,6 +127,6 @@ Outstanding items are currently in the TODO.md file. ### Pre-Push Hook -There is a pre-push hook present in ```.githooks/pre-push.sh```. This can be symlinked to ```.git/hooks/pre-push```. +There is a pre-push hook present in `.githooks/pre-push.sh`. This can be symlinked to `.git/hooks/pre-push`. This will ensure that the same checks that will be run in CI are run when you push. diff --git a/lua/hawtkeys/init.lua b/lua/hawtkeys/init.lua index 48c15d4..5ba18bb 100644 --- a/lua/hawtkeys/init.lua +++ b/lua/hawtkeys/init.lua @@ -3,8 +3,6 @@ ---@field package defaultConfig HawtKeyConfig local M = {} ----@alias HawtKeySupportedKeyboardLayouts "qwerty" | "dvorak" - ---@class HawtKeyConfig ---@field leader string ---@field homerow number diff --git a/lua/hawtkeys/keyboards.lua b/lua/hawtkeys/keyboards.lua index 3c3debb..60d34b2 100644 --- a/lua/hawtkeys/keyboards.lua +++ b/lua/hawtkeys/keyboards.lua @@ -1,5 +1,10 @@ local M = {} -- TODO: Make this dynamic, loading from the keyboards directory + +---@alias HawtKeySupportedKeyboardLayouts "qwerty" | "colemak" | "colemak-dh" + M.qwerty = require("hawtkeys.keyboards.qwerty").layout +M.colemak = require("hawtkeys.keyboards.colemak").layout +M.colemakdh = require("hawtkeys.keyboards.colemak-dh").layout return M diff --git a/lua/hawtkeys/keyboards/colemak-dh.lua b/lua/hawtkeys/keyboards/colemak-dh.lua new file mode 100644 index 0000000..a8b8359 --- /dev/null +++ b/lua/hawtkeys/keyboards/colemak-dh.lua @@ -0,0 +1,44 @@ +local layout = { + q = { finger = 1, row = 1, col = 1 }, + w = { finger = 2, row = 1, col = 2 }, + f = { finger = 3, row = 1, col = 3 }, + p = { finger = 4, row = 1, col = 4 }, + b = { finger = 4, row = 1, col = 5 }, + j = { finger = 6, row = 1, col = 6 }, + l = { finger = 6, row = 1, col = 7 }, + u = { finger = 7, row = 1, col = 8 }, + y = { finger = 7, row = 1, col = 9 }, + + a = { finger = 1, row = 2, col = 1 }, + r = { finger = 2, row = 2, col = 2 }, + s = { finger = 3, row = 2, col = 3 }, + t = { finger = 3, row = 2, col = 4 }, + g = { finger = 3, row = 2, col = 5 }, + m = { finger = 6, row = 2, col = 6 }, + n = { finger = 7, row = 2, col = 7 }, + e = { finger = 7, row = 2, col = 8 }, + i = { finger = 8, row = 2, col = 9 }, + o = { finger = 8, row = 2, col = 10 }, + + z = { finger = 1, row = 3, col = 1 }, + x = { finger = 3, row = 3, col = 2 }, + c = { finger = 3, row = 3, col = 3 }, + d = { finger = 3, row = 3, col = 4 }, + v = { finger = 6, row = 3, col = 5 }, + k = { finger = 6, row = 3, col = 6 }, + h = { finger = 6, row = 3, col = 7 }, + + [" "] = { finger = 4, row = 4, col = 6 }, -- Spacebar +} + +return { + layout = layout, +} + +-- https://colemakmods.github.io/mod-dh/ +-- NOTE: Angled mode is not accounted for since that would involve moving punctuation + +------1-2-3-4-5-6-7-8-9-0 +---1- q w f p b j l u y +---2- a r s t g m n e i o +---3- z x c d v k h diff --git a/lua/hawtkeys/keyboards/colemak.lua b/lua/hawtkeys/keyboards/colemak.lua new file mode 100644 index 0000000..a9b0d45 --- /dev/null +++ b/lua/hawtkeys/keyboards/colemak.lua @@ -0,0 +1,43 @@ +local layout = { + q = { finger = 1, row = 1, col = 1 }, + w = { finger = 2, row = 1, col = 2 }, + f = { finger = 3, row = 1, col = 3 }, + p = { finger = 4, row = 1, col = 4 }, + g = { finger = 4, row = 1, col = 5 }, + j = { finger = 6, row = 1, col = 6 }, + l = { finger = 6, row = 1, col = 7 }, + u = { finger = 7, row = 1, col = 8 }, + y = { finger = 7, row = 1, col = 9 }, + + a = { finger = 1, row = 2, col = 1 }, + r = { finger = 2, row = 2, col = 2 }, + s = { finger = 3, row = 2, col = 3 }, + t = { finger = 3, row = 2, col = 4 }, + d = { finger = 3, row = 2, col = 5 }, + h = { finger = 6, row = 2, col = 6 }, + n = { finger = 7, row = 2, col = 7 }, + e = { finger = 7, row = 2, col = 8 }, + i = { finger = 8, row = 2, col = 9 }, + o = { finger = 8, row = 2, col = 10 }, + + z = { finger = 1, row = 3, col = 1 }, + x = { finger = 3, row = 3, col = 2 }, + c = { finger = 3, row = 3, col = 3 }, + v = { finger = 3, row = 3, col = 4 }, + b = { finger = 6, row = 3, col = 5 }, + k = { finger = 6, row = 3, col = 6 }, + m = { finger = 6, row = 3, col = 7 }, + + [" "] = { finger = 4, row = 4, col = 6 }, -- Spacebar +} + +return { + layout = layout, +} + +-- https://colemak.com/ + +------1-2-3-4-5-6-7-8-9-0 +---1- q w f p g j l u y +---2- a r s t d h n e i o +---3- z x c v b k m diff --git a/lua/hawtkeys/keyboards/qwerty.lua b/lua/hawtkeys/keyboards/qwerty.lua index 5dfaa61..aee86ea 100644 --- a/lua/hawtkeys/keyboards/qwerty.lua +++ b/lua/hawtkeys/keyboards/qwerty.lua @@ -35,3 +35,8 @@ local layout = { return { layout = layout, } + +------1-2-3-4-5-6-7-8-9-0 +---1- q w e r t y u i o p +---2- a s d f g h j k l +---3- z x c v b n m From 4d700a064e04a493e53f1108488a3a502e4fecaf Mon Sep 17 00:00:00 2001 From: tris203 Date: Thu, 4 Jan 2024 16:02:19 +0000 Subject: [PATCH 2/2] chore(docs): autogenerate vimdoc --- doc/hawtkeys.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/hawtkeys.txt b/doc/hawtkeys.txt index eb4b61f..a03f1a2 100644 --- a/doc/hawtkeys.txt +++ b/doc/hawtkeys.txt @@ -7,6 +7,7 @@ Table of Contents *hawtkeys-table-of-contents* - Installation |hawtkeys-hawtkeys.nvim-installation| - Usage |hawtkeys-hawtkeys.nvim-usage| - Config |hawtkeys-hawtkeys.nvim-config| + - Keyboard Layouts |hawtkeys-hawtkeys.nvim-keyboard-layouts| - Contributing |hawtkeys-hawtkeys.nvim-contributing| ============================================================================== @@ -117,6 +118,21 @@ The default config will get all keymaps using the `vim.api.nvim_set_keymap` and `vim.keymap.set`. +KEYBOARD LAYOUTS *hawtkeys-hawtkeys.nvim-keyboard-layouts* + +Currently supported keyboard layouts are: + +- qwerty +- colemak +- colemak-dh + +We would welcome any PRs to add keyboard layouts. + +Keyboard Contributors: + +- @delinx + + CONTRIBUTING *hawtkeys-hawtkeys.nvim-contributing* Contributions are what makes the open-source community such an amazing place to @@ -151,6 +167,7 @@ push. 2. Links *hawtkeys-links* 1. *demo*: https://github.com/tris203/hawtkeys.nvim/assets/18444302/5ede9881-34d5-4ef4-a15d-80f2c94b314d +2. *@delinx*: Generated by panvimdoc