I don't know if you've noticed but qwerty is f***ing everywhere. I think it sucks so I opt for a alternate layout when I can.
I put most of my keybindings on my homerows for convenience but when I switch between my laptop and my sick lightup colemak-dh keyboard, things gets messed up.
If only there was a way to easily switch between keyboard layouts and keep my homerow keybindings.
Then I thought, "I don't make the rules but I do make shitty nvim plugins."
Homerows allows you to map your keybindings to the position of the key and not the letter making it impeccably easy to maintain your keybinding positions across various keyboard layouts.
The key positions follow the diagrams below, with the naming convention:
HAND - FINGER - VERTICALITY
The middle row drops the VERTICALITY indicator for brevity's sake as it is default.
To capitalise the letter, making the HAND portion capital.
name | hand | finger | vert | qwerty | colemak |
---|---|---|---|---|---|
l0 | left | first | middle | g | g |
r3t | right | third | top | o | y |
L1b | left | first | bottom | V | D |
local hr = require("homerows.homerows")
vim.keymap.set(
'n',
'<leader>' .. hr.l3 .. hr.R1b,
function() do_stuff() end,
{ desc = "does things" }
)
Use a package manager of your choice; examples using common one below. Requires plenary.nvim.
use {
"kbario/homerows.nvim",
requires = {"nvim-lua/plenary.nvim"} -- if you don't have it already
}
Plug "nvim-lua/plenary.nvim" " if you don't have it already
Plug "kbario/homerows.nvim"
global settings of homerows that are set on setup:
settings = {
-- used to give preference to ripples. see ripples below.
pref = { "programmers_dvorak", "colemak_dh" }
-- whether or not to add the keybinding for changing the current homerows layout
add_change_keymap = true,
-- whether or not to add the keybinding for printing the current homerows layout
add_print_keymap = true
-- where you add layouts that don't come standard with homerows.
custom_layouts = {
your_layout = {
r1 = "a",
r2 = "b",
...
}
}
}
Current layouts that come with homerows include
- qwerty
- dvorak
- programmers dvorak
- colemak
- colemak-dh
Add your own in the custom layouts attribute of the global settings object. Find a premade custom_layouts object below to copy and paste into your config to save time.
If you think there's a layout that should come standard with homerows, make a PR.
This command changes the keyboard layout that homerows is using to determine the what keys are in what positions. Either type the layout you're using (i.e. qwerty, colemak, etc.) or you can use a ripple (i.e. asdf, arst, etc.).
Enable or disable the default keybinding for this command - "<leader>hrt"
- with
add_change_keymap = true/false
in the setup of homerows. Or use another keybinding by supplying the mapping as the value (i.e.
add_change_keymap = '<leader> .. hr.l1t .. hr.l2t'
forgot what keyboard layout you're using? "<leader>hra"
prints this in the bottom bar, or change it in the setup.
at present, this does not reload your neovim so you will need to restart for the changes to take effect. If you know how to do this, please make a pull request to change it.