1
0
Fork 0
dotfiles/.config/nvim/lua/config/mappings.lua
2026-01-30 15:47:24 +03:00

64 lines
2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local map = vim.keymap.set
-- Remap leader to <Space>
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
map({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- Unbind keys
map('n', '<C-q>', '<NOP>')
map({ 'n', 'v' }, 'H', '<NOP>')
map({ 'n', 'v' }, 'L', '<NOP>')
map({ 'n', 'v' }, '<C-Space>', '<NOP>')
-- Movement between buffers
map({ 'n', 'v' }, '<A-u>', ':bp<CR>', { silent = true })
map({ 'n', 'v' }, '<A-i>', ':bn<CR>', { silent = true })
-- Remap for dealing with word wrap
map({ 'n', 'v' }, 'j', 'v:count == 0 ? "gj" : "j"', { expr = true, silent = true })
map({ 'n', 'v' }, 'k', 'v:count == 0 ? "gk" : "k"', { expr = true, silent = true })
map({ 'n', 'v' }, 'о', 'v:count == 0 ? "gj" : "j"', { expr = true, silent = true })
map({ 'n', 'v' }, 'л', 'v:count == 0 ? "gk" : "k"', { expr = true, silent = true })
-- Duplicate leader feats to gradually move to
-- Copy and paste from clipboard
map({ 'n', 'v' }, '<leader>y', '"+y')
map({ 'n', 'v' }, '<leader>Y', '"+y$')
map({ 'n', 'v' }, '<leader>p', '"+p<ESC>')
map({ 'n', 'v' }, '<leader>P', '"+P<ESC>')
map({ 'n', 'v' }, '<leader>н', '"+y')
map({ 'n', 'v' }, '<leader>н', '"+y$')
map({ 'n', 'v' }, '<leader>з', '"+p<ESC>')
map({ 'n', 'v' }, '<leader>З', '"+P<ESC>')
-- buffer size
map({ 'n', 'v' }, '<leader>n', '<C-w>10<')
map({ 'n', 'v' }, '<leader>m', '<C-w>10>')
map({ 'n', 'v' }, '<leader>N', '<C-w>6-')
map({ 'n', 'v' }, '<leader>M', '<C-w>6+')
-- goto files
map('n', '<leader>f', 'gF')
-- Close buffers quickly
map('n', '<C-q>', ":bd<CR>", { silent = true })
-- quickfix buffer
map('n', '<M-n>', ':cn<CR>', { silent = true })
map('n', '<M-p>', ':cp<CR>', { silent = true })
-- Remap <M-BS> to remove last word
map('i', '<M-BS>', '<C-w>')
-- Move lines quickly
map('n', '<C-M-k>', ':m-2<CR>', { silent = true })
map('n', '<C-M-j>', ':m+1<CR>', { silent = true })
map('n', '<Leader>dt', ':diffthis<CR>', { silent = true })
map('n', '<Leader>do', ':diffoff<CR>', { silent = true })
map('n', '<Leader>lr', ':LspR<CR>')