52 lines
1.8 KiB
Lua
52 lines
1.8 KiB
Lua
|
|
-- Personal keymaps (plugin-agnostic). Plugin-bound keys live in their specs.
|
||
|
|
|
||
|
|
local function map(mode, lhs, rhs, opts)
|
||
|
|
local options = { noremap = true, silent = true }
|
||
|
|
if opts then
|
||
|
|
options = vim.tbl_extend('force', options, opts)
|
||
|
|
end
|
||
|
|
vim.keymap.set(mode, lhs, rhs, options)
|
||
|
|
end
|
||
|
|
|
||
|
|
local function no(lhs, rhs) map('n', lhs, rhs, { silent = false }) end
|
||
|
|
local function no_s(lhs, rhs) map('n', lhs, rhs) end
|
||
|
|
local function no_r(lhs, rhs) map('n', lhs, rhs, { noremap = false, silent = false }) end
|
||
|
|
local function i(lhs, rhs) map('i', lhs, rhs, { silent = false }) end
|
||
|
|
local function i_s(lhs, rhs) map('i', lhs, rhs) end
|
||
|
|
local function v_s(lhs, rhs) map('v', lhs, rhs) end
|
||
|
|
|
||
|
|
-- disable arrow keys and middle-click (muscle memory from the old config)
|
||
|
|
no_s('<up>', '<nop>')
|
||
|
|
no_s('<down>', '<nop>')
|
||
|
|
no_s('<left>', '<nop>')
|
||
|
|
no_s('<right>', '<nop>')
|
||
|
|
no_s('<c-left>', '<nop>')
|
||
|
|
no_s('<c-right>', '<nop>')
|
||
|
|
v_s('<up>', '<nop>')
|
||
|
|
v_s('<down>', '<nop>')
|
||
|
|
v_s('<left>', '<nop>')
|
||
|
|
v_s('<right>', '<nop>')
|
||
|
|
v_s('<c-left>', '<nop>')
|
||
|
|
v_s('<c-right>', '<nop>')
|
||
|
|
|
||
|
|
-- escape from insert mode on home-row bigrams
|
||
|
|
i_s('jj', '<esc>')
|
||
|
|
i_s('jk', '<esc>')
|
||
|
|
i_s('kj', '<esc>')
|
||
|
|
i_s('чя', '<esc>')
|
||
|
|
|
||
|
|
i_s('<esc>', '<nop>')
|
||
|
|
i_s('<C-c>', '<nop>')
|
||
|
|
|
||
|
|
-- bracket-return expansions: open a line between the delimiters, indented
|
||
|
|
i('[<CR>', '[<CR>]<Esc>O<BS><Tab>')
|
||
|
|
i('{<CR>', '{<CR>}<Esc>O<BS><Tab>')
|
||
|
|
i('(<CR>', '(<CR>)<Esc>O<BS><Tab>')
|
||
|
|
|
||
|
|
vim.keymap.set({ 'n', 'i', 'v' }, '<LeftMouse>', '<nop>')
|
||
|
|
|
||
|
|
-- Russian-layout fixes: `ж` types `:`, `W`/`E`/`w'` expand in cmdline
|
||
|
|
no_r('ж', ':')
|
||
|
|
vim.cmd.cnoreabbrev({ "<expr> W", "((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))" })
|
||
|
|
vim.cmd.cnoreabbrev({ "<expr> E", "((getcmdtype() is# ':' && getcmdline() is# 'E')?('e'):('E'))" })
|
||
|
|
vim.cmd.cnoreabbrev({ "<expr> w'", "(getcmdtype() == \":\" && getcmdline() == \"w'\" ? \"w\" : \"w'\")" })
|