2023-08-26 11:47:29 +03:00
|
|
|
|
2023-11-20 07:26:11 +03:00
|
|
|
local function escape(str)
|
|
|
|
local escape_chars = [[;,."|\]]
|
|
|
|
return vim.fn.escape(str, escape_chars)
|
|
|
|
end
|
|
|
|
|
|
|
|
local en_shift = [[~QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>]]
|
|
|
|
local ru_shift = [[ËЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ]]
|
|
|
|
local en = [[`qwertyuiop[]asdfghjkl;'zxcvbnm]]
|
|
|
|
local ru = [[ёйцукенгшщзхъфывапролджэячсмить]]
|
|
|
|
vim.opt.langmap = vim.fn.join({
|
|
|
|
escape(ru_shift) .. ';' .. escape(en_shift),
|
|
|
|
escape(ru) .. ';' .. escape(en),
|
|
|
|
}, ',')
|
|
|
|
|
2023-08-27 13:31:42 +03:00
|
|
|
vim.o.timeout = false
|
2023-08-26 11:47:29 +03:00
|
|
|
-- Key mapping
|
|
|
|
local map = vim.api.nvim_set_keymap
|
|
|
|
|
|
|
|
-- Configuration fast editing.
|
2023-09-19 15:22:41 +03:00
|
|
|
local opts = {nowait=true, silent = true}
|
2023-09-10 13:36:08 +03:00
|
|
|
map('n', '\\rconf', ':source $HOME/lib/nvim/init.lua\n', opts)
|
|
|
|
map('n', '\\econf', ':e $HOME/lib/nvim/init.lua\n', opts)
|
|
|
|
map('n', '\\emap', ':e $HOME/lib/nvim/lua/maps.lua\n', opts)
|
2023-09-19 15:29:16 +03:00
|
|
|
map('n', '\\ic', ':set ic!\n', opts)
|
2023-08-26 12:20:56 +03:00
|
|
|
|
2023-10-30 12:00:24 +03:00
|
|
|
map('n', '<Return>', 'o<Esc>', opts)
|
|
|
|
|
2023-09-07 09:21:41 +03:00
|
|
|
-- Quit
|
|
|
|
map('n', '\\q', ":quit\n", opts)
|
|
|
|
map('n', '\\qa', ":qa\n", opts)
|
|
|
|
|
2023-08-29 13:42:38 +03:00
|
|
|
-- Moving around.
|
2023-09-10 13:36:08 +03:00
|
|
|
map('n', '\\home', ":cd $HOME\n", opts)
|
|
|
|
map('n', '\\cd', ":cd ", {silent = false})
|
|
|
|
map('n', '\\lcd', ":lcd ", {silent = false})
|
|
|
|
map('n', '\\tcd', ":tcd ", {silent = false})
|
|
|
|
map('n', '\\pwd', ':pwd\n', {silent = false})
|
2023-09-07 09:21:41 +03:00
|
|
|
map('n', '\\aa', ':argadd ', {silent = false})
|
|
|
|
map('n', '\\bb', ':b ', {silent = false})
|
|
|
|
map('n', '\\b#', ':b#\n ', {silent = true})
|
2023-08-29 13:42:38 +03:00
|
|
|
|
2023-08-29 17:39:24 +03:00
|
|
|
map('n', '\\lex', ":Lexplore\n", opts)
|
|
|
|
map('n', '\\ex', ":Explore\n", opts)
|
|
|
|
|
2023-08-29 13:42:38 +03:00
|
|
|
-- Search
|
|
|
|
map('n', '\\noh', ':noh\n', opts)
|
2023-08-26 11:47:29 +03:00
|
|
|
|
2023-08-26 12:20:56 +03:00
|
|
|
-- Tabs.
|
2023-09-10 13:36:08 +03:00
|
|
|
map('n', '\\tn', ':tabnew\n', opts)
|
2023-08-26 11:47:29 +03:00
|
|
|
|
2023-09-10 12:10:15 +03:00
|
|
|
-- Fold
|
2023-09-20 19:45:45 +03:00
|
|
|
map('n', '<2-LeftMouse>', 'za', opts)
|
2023-09-07 09:21:41 +03:00
|
|
|
-- Insert
|
2023-09-10 13:36:08 +03:00
|
|
|
-- Literal tabs with Shift-Tab
|
|
|
|
map('i', '<S-Tab>', '\t', opts)
|
|
|
|
map('n', '<Backspace>', 'hx', opts)
|
2023-08-26 15:09:08 +03:00
|
|
|
|
2023-09-07 09:21:41 +03:00
|
|
|
-- Empty
|
|
|
|
map('n', '<C-l>', '', opts)
|
2023-09-10 13:36:08 +03:00
|
|
|
|
|
|
|
-- Help.
|
|
|
|
map('n', '\\th', ":tab help ", {silent=false})
|
2023-09-07 09:21:41 +03:00
|
|
|
-- vim.api.nvim_del_keymap('n', '<C-l>')
|
|
|
|
-- vim.api.nvim_del_keymap('n', '<C-r>')
|
2023-08-26 11:47:29 +03:00
|
|
|
-- Windows
|
2023-09-10 13:36:08 +03:00
|
|
|
-- Moving
|
|
|
|
map('n', '<S-b>', '<C-b>', opts)
|
|
|
|
map('n', '<S-f>', '<C-f>', opts)
|
|
|
|
opts = {silent = true}
|
|
|
|
map('n', '<A-l>', '<C-w>l', opts)
|
|
|
|
map('n', '<A-h>', '<C-w>h', opts)
|
|
|
|
map('n', '<A-k>', '<C-w>k', opts)
|
|
|
|
map('n', '<A-j>', '<C-w>j', opts)
|
2023-09-19 15:22:41 +03:00
|
|
|
|
|
|
|
map('n', 'gl', '<C-w>l', opts)
|
|
|
|
map('n', 'gh', '<C-w>h', opts)
|
|
|
|
map('n', 'gk', '<C-w>k', opts)
|
|
|
|
map('n', 'gj', '<C-w>j', opts)
|
2023-09-10 13:36:08 +03:00
|
|
|
-- Resizing
|
|
|
|
map('n', '+', '<C-w>+', opts)
|
|
|
|
map('n', '-', '<C-w>-', opts)
|
|
|
|
-- map('n', '<C-h>', '3<C-w><', opts)
|
|
|
|
-- map('n', '<C-l>', '3<C-w>>', opts)
|
|
|
|
map('n', '<Space>', '3<C-w>>', opts)
|
|
|
|
map('n', '<C-Space>', '3<C-w><', opts)
|
|
|
|
-- Splitting
|
|
|
|
map('n', '\\|', '<C-w>v', opts)
|
|
|
|
map('n', '\\-', '<C-w>s', opts)
|
2023-08-26 11:47:29 +03:00
|
|
|
|
2023-10-20 12:10:21 +03:00
|
|
|
-- Move
|
|
|
|
map('n', 'L', '$', opts)
|
|
|
|
map('n', 'H', '^', opts)
|
|
|
|
|
2023-09-07 09:21:41 +03:00
|
|
|
-- Netrw
|
|
|
|
vim.api.nvim_create_autocmd('filetype', {
|
|
|
|
pattern = 'netrw',
|
|
|
|
callback = function()
|
2023-09-10 13:36:08 +03:00
|
|
|
local buf = vim.api.nvim_get_current_buf()
|
|
|
|
vim.api.nvim_buf_set_keymap(buf, "n", 'f', '%', opts)
|
2023-09-07 09:21:41 +03:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|