This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmapping.lua
208 lines (205 loc) · 5.24 KB
/
mapping.lua
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
local api = require("utils.api")
local M = {}
api.map.bulk_register({
{
mode = { "n" },
lhs = "<leader><esc>",
rhs = ":qa!<cr>",
options = { silent = true },
description = "Escape Neovim",
},
{
mode = { "i" },
lhs = "jj",
rhs = "<esc>",
options = { silent = true },
description = "Escape editor insert mode",
},
{
mode = { "t" },
lhs = "<esc>",
rhs = "<c-\\><c-n>",
options = { silent = true },
description = "Escape terminal insert mode",
},
{
mode = { "n" },
lhs = "<esc>",
rhs = ":noh<cr>",
options = { silent = true },
description = "Clear search highlight",
},
{
mode = { "n" },
lhs = "<c-u>",
rhs = function()
vim.cmd("normal! " .. math.ceil(vim.api.nvim_win_get_height(0) / 4) .. "k")
end,
options = { silent = true },
description = "Move 1/4 screen up",
},
{
mode = { "n" },
lhs = "<c-d>",
rhs = function()
vim.cmd("normal! " .. math.ceil(vim.api.nvim_win_get_height(0) / 4) .. "j")
end,
options = { silent = true },
description = "Move 1/4 screen down",
},
{
mode = { "n" },
lhs = "<m-k>",
rhs = "<c-w>-",
options = { silent = true },
description = "Reduce horizontal split screen size",
},
{
mode = { "n" },
lhs = "<m-j>",
rhs = "<c-w>+",
options = { silent = true },
description = "Increase horizontal split screen size",
},
{
mode = { "n" },
lhs = "<m-h>",
rhs = "<c-w><",
options = { silent = true },
description = "Reduce vertical split screen size",
},
{
mode = { "n" },
lhs = "<m-l>",
rhs = "<c-w>>",
options = { silent = true },
description = "Increase vertical split screen size",
},
{
mode = { "n" },
lhs = "<leader>cs",
rhs = "<cmd>set spell!<cr>",
options = { silent = true },
description = "Enable or disable spell checking",
},
{
mode = { "c" },
lhs = "<m-p>",
rhs = "<up>",
options = {},
description = "Look up history",
},
{
mode = { "c" },
lhs = "<m-n>",
rhs = "<down>",
options = {},
description = "Look down history",
},
{
mode = { "n", "x" },
lhs = "k",
rhs = function()
return vim.v.count > 0 and "k" or "gk"
end,
options = { silent = true, expr = true },
description = "Move up one line",
},
{
mode = { "n", "x" },
lhs = "j",
rhs = function()
return vim.v.count > 0 and "j" or "gj"
end,
options = { silent = true, expr = true },
description = "Move down one line",
},
{
mode = { "n", "x" },
lhs = "H",
rhs = function()
return vim.v.count > 0 and "^" or "g^"
end,
options = { silent = true, expr = true },
description = "Move to the first character at the beginning of the line",
},
{
mode = { "n", "x" },
lhs = "L",
rhs = function()
return vim.v.count > 0 and "$" or "g$"
end,
options = { silent = true, expr = true },
description = "Move to the last character at the end of the line",
},
{
mode = { "i", "c", "t" },
lhs = "<m-w>",
rhs = "<c-right>",
options = {},
description = "Jump to next word in insert mode",
},
{
mode = { "i", "c", "t" },
lhs = "<m-b>",
rhs = "<c-left>",
options = {},
description = "Jump to previous word in insert mode",
},
{
mode = { "i", "c", "t" },
lhs = "<m-k>",
rhs = "<up>",
options = {},
description = "Move cursor up in insert mode",
},
{
mode = { "i", "c", "t" },
lhs = "<m-j>",
rhs = "<down>",
options = {},
description = "Move cursor down in insert mode",
},
{
mode = { "i", "c", "t" },
lhs = "<m-h>",
rhs = "<left>",
options = {},
description = "Move cursor left in insert mode",
},
{
mode = { "i", "c", "t" },
lhs = "<m-l>",
rhs = "<right>",
options = {},
description = "Move cursor right in insert mode",
},
{
mode = { "n" },
lhs = "dd",
rhs = function()
if vim.api.nvim_get_current_line():match("^%s*$") then
return '"_dd'
else
return "dd"
end
end,
options = { expr = true },
description = "Delete empty lines without writing to registers",
},
{
mode = { "n" },
lhs = "i",
rhs = function()
local cond = #vim.fn.getline(".") == 0
if cond then
return '"_cc'
else
return "i"
end
end,
options = { expr = true },
description = "When you press i, automatically indent to the appropriate position",
},
})
return M