1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
local map = vim.api.nvim_set_keymap
-- Easy ESC
map('i', 'jk', '<esc>', {noremap = true, silent = true})
map('i', 'kj', '<esc>', {noremap = true, silent = true})
map('n', '<Esc>', '<cmd>nohlsearch<CR>', {})
-- TAB in normal mode will move to next buffer
map('n', '<TAB>', ':bnext<cr>', {noremap = true, silent = true})
---------- My configuration ----------
-- Window and buffer management
--------------------
map('n', '<Leader>h', ':wincmd h<cr>', {noremap = true})
map('n', '<Leader>j', ':wincmd j<cr>', {noremap = true})
map('n', '<Leader>k', ':wincmd k<cr>', {noremap = true})
map('n', '<Leader>l', ':wincmd l<cr>', {noremap = true})
map('n', '<Leader>1', ':only<cr>', {noremap = true})
map('n', '<Leader>c', ':close<cr>', {noremap = true})
map('n', '<Leader>v', ':vsplit<cr><cr>', {noremap = true})
map('n', '<Leader>s', ':split<cr><cr>', {noremap = true})
map('n', '<Leader>d', ':bd!<cr>', {noremap = true})
-- Placeholders
--------------------
map('n', '<Leader><space>', '/<++><cr>ca<', {noremap = true})
-- Terminal
--------------------
map('t', '<ESC>', '<C-\\><C-n>', {noremap = true})
map('t', 'jk', '<C-\\><C-n>', {noremap = true})
-- Registers
--------------------
map('n', 'dD', '"_dd', {noremap = true})
-- Quickfix
--------------------
map('n', '<C-j>', ':cn<CR>', {noremap = true})
map('n', '<C-k>', ':cp<CR>', {noremap = true})
-- map('n', '<C-q>', ':lua require("mappings.lua").quickfix_open()<CR>', {noremap = true})
---------- Movements ----------
-- Make arrows useful
map('n', '<down>', 'ddp', {})
map('n', '<right>', 'dwea<space><esc>pxb', {})
map('n', '<left>', 'dwbPa<space><esc>b', {})
map('n', '<up>', 'ddkP', {})
-- Disable arrows
map('i', '<down>', '<nop>', {})
map('i', '<right>', '<nop>', {})
map('i', '<left>', '<nop>', {})
map('i', '<up>', '<nop>', {})
map('v', '<down>', '<nop>', {})
map('v', '<right>', '<nop>', {})
map('v', '<left>', '<nop>', {})
map('v', '<up>', '<nop>', {})
-- Make some room
--------------------
map('n', 'go', 'o<esc>k', {})
map('n', 'gO', 'O<esc>j', {})
-- Center the screen
--------------------
map('n', 'G', 'Gzz', {noremap = true})
map('n', 'n', 'nzz', {})
map('n', 'N', 'Nzz', {})
-- Shortcuts
--------------------
map('n', '<Leader>cc', ':e $MYVIMRC<cr>', {noremap = true})
map('n', '<Leader>cr', ':luafile $MYVIMRC<cr>', {noremap = true})
map('n', '<C-c>', ':make<cr>', {noremap = true})
---------- Plugins ----------
-- Git
--------------------
map('n', '<Leader>.', ':Neogit<cr>', {noremap = true})
-- Termdebug
--------------------
map('n', '<Leader>ge', ':Eval<cr>', {noremap = true})
map('n', '<Leader>gn', ':Over<cr>', {noremap = true})
map('n', '<Leader>gb', ':Break<cr>', {noremap = true})
map('n', '<Leader>gc', ':Cont<cr>', {noremap = true})
|