-
Notifications
You must be signed in to change notification settings - Fork 0
/
mappings.lua
244 lines (226 loc) · 11 KB
/
mappings.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
local toggle_term_cmd = astronvim.toggle_term_cmd
return {
n = {
-- NOTE: conflict with split
-- ["<C-s>"] = {":w!<CR>"},
[";"] = { ":", nowait = true },
["yc"] = { function() require("utils.fs").rel_path() end, desc = "Copy current file relative path" },
["<ESC>"] = { "<cmd>nohl<cr>", desc = "No highlight" },
-- [";"] = { "<cmd>FineCmdline<cr>", nowait = true, desc = "Floating cmd input" },
-- resize
["<A-l>"] = { "<cmd>vertical resize +2<CR>" },
["<A-h>"] = { "<cmd>vertical resize -2<CR>" },
["<A-j>"] = { "<cmd>resize -2<CR>" },
["<A-k>"] = { "<cmd>resize +2<CR>" },
["<A-=>"] = { "<C-w>=", desc = "Resize equal" },
-- navigation
["<C-u>"] = { "10k", desc = "Move up 10 lines" },
["<C-d>"] = { "10j", desc = "Move down 10 lines" },
["<A-t>"] = {
function()
local input = vim.fn.input "Buf number: "
local num = tonumber(input, 10)
if num == nil then
return
else
require("bufferline").go_to_buffer(num, true)
end
end,
desc = "Go to buffer by absolute number",
noremap = true,
silent = true,
},
["<A-1>"] = { function() require("bufferline").go_to_buffer(1, false) end, noremap = true, silent = true },
["<A-2>"] = { function() require("bufferline").go_to_buffer(2, false) end, noremap = true, silent = true },
["<A-3>"] = { function() require("bufferline").go_to_buffer(3, false) end, noremap = true, silent = true },
["<A-4>"] = { function() require("bufferline").go_to_buffer(4, false) end, noremap = true, silent = true },
["<A-5>"] = { function() require("bufferline").go_to_buffer(5, false) end, noremap = true, silent = true },
["<A-6>"] = { function() require("bufferline").go_to_buffer(6, false) end, noremap = true, silent = true },
["<A-7>"] = { function() require("bufferline").go_to_buffer(7, false) end, noremap = true, silent = true },
["<A-8>"] = { function() require("bufferline").go_to_buffer(8, false) end, noremap = true, silent = true },
["<A-9>"] = { function() require("bufferline").go_to_buffer(9, false) end, noremap = true, silent = true },
["<A-0>"] = { function() require("bufferline").go_to_buffer(-1, false) end, noremap = true, silent = true },
["<A->>"] = { "<cmd>BufferLineMoveNext<CR>", noremap = true, silent = true },
["<A-<>"] = { "<cmd>BufferLineMovePrev<CR>", noremap = true, silent = true },
-- split
["<A-v>"] = { "<C-w>v", desc = "Split window vertically" },
["<A-s>"] = { "<C-w>s", desc = "Split window horizontally" },
-- multi-cursor
["<A-K>"] = { "<cmd>call vm#commands#add_cursor_up(0, v:count1)<cr>" },
["<A-J>"] = { "<cmd>call vm#commands#add_cursor_down(0, v:count1)<cr>" },
-- quickfix list
["qfj"] = { "<cmd>cnewer<cr>" },
["qfk"] = { "<cmd>colder<cr>" },
["qfo"] = { "<cmd>copen<cr>" },
-- terminal
["<A-o>"] = { "<cmd>ToggleTerm direction=float<cr>", desc = "Toggle floating terminal" },
["<A-H>"] = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", desc = "Toggle horizontal terminal" },
["<A-V>"] = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", desc = "Toggle vertical terminal" },
-- ["<leader>gg"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" },
["<leader>tn"] = { function() toggle_term_cmd "node-prototype-repl" end, desc = "ToggleTerm node" },
-- ["<leader>tu"] = { function() toggle_term_cmd "gdu" end, desc = "ToggleTerm gdu" },
["<leader>tp"] = { function() toggle_term_cmd "ipython" end, desc = "ToggleTerm python" },
["<leader>tb"] = { function() toggle_term_cmd "btop" end, desc = "ToggleTerm btm" },
["<leader>tc"] = { function() toggle_term_cmd "navi" end, desc = "ToggleTerm navi" },
["<leader>tl"] = false,
["<leader>tf"] = false,
["<leader>th"] = false,
["<leader>tv"] = false,
-- close buffer
["<leader>C"] = {
'<cmd>sil! exe "wa|%bd|e#|bd#|normal `"<cr>"',
desc = "Save and close other buffers",
},
["<leader>bo"] = {
'<cmd>sil! exe "%bd|e#|bd#|normal `"<cr>"',
desc = "Close other buffers except unsaved",
},
-- Aerial
["<C-b>"] = { "<cmd>AerialToggle<cr>" },
-- trouble
["<leader>xx"] = { "<cmd>TroubleToggle document_diagnostics<cr>", noremap = true, silent = true },
["<leader>xq"] = { "<cmd>TroubleToggle quickfix<cr>", noremap = true, silent = true },
["<leader>xl"] = { "<cmd>TroubleToggle loclist<cr>", noremap = true, silent = true },
["<leader>xr"] = { "<cmd>TroubleToggle lsp_references<cr>", noremap = true, silent = true },
["gxj"] = {
function() require("trouble").next { skip_groups = true, jump = true } end,
noremap = true,
silent = true,
},
["gxk"] = {
function() require("trouble").previous { skip_groups = true, jump = true } end,
noremap = true,
silent = true,
},
["gxf"] = {
function() require("trouble").first { skip_groups = true, jump = true } end,
noremap = true,
silent = true,
},
["gxl"] = {
function() require("trouble").last { skip_groups = true, jump = true } end,
noremap = true,
silent = true,
},
-- git diff vieww
["gdo"] = { "<cmd>DiffviewOpen<CR>" },
["gdc"] = { "<cmd>DiffviewClose<CR>" },
["gdf"] = { "<cmd>DiffviewFileHistory<CR>" },
-- git conflict
["gco"] = { "<cmd>GitConflictChooseOurs<CR>" },
["gct"] = { "<cmd>GitConflictChooseTheirs<CR>" },
["gcB"] = { "<cmd>GitConflictChooseBase<CR>" },
["gcb"] = { "<cmd>GitConflictChooseBoth<CR>" },
["gcn"] = { "<cmd>GitConflictChooseNone<CR>" },
["gcj"] = { "<cmd>GitConflictNextConflict<CR>" },
["gck"] = { "<cmd>GitConflictPrevConflict<CR>" },
["gcq"] = { "<cmd>GitConflictListQf<CR>" },
-- gitsigns
["ghj"] = { function() require("gitsigns").next_hunk() end, desc = "Next git hunk" },
["ghk"] = { function() require("gitsigns").prev_hunk() end, desc = "Previous git hunk" },
-- ["gbl"] = { function() require("gitsigns").blame_line() end, desc = "View git blame" },
["ghp"] = { function() require("gitsigns").preview_hunk() end, desc = "Preview git hunk" },
["ghr"] = { function() require("gitsigns").reset_hunk() end, desc = "Reset git hunk" },
["ghs"] = { function() require("gitsigns").stage_hunk() end, desc = "Stage git hunk" },
["ghu"] = { function() require("gitsigns").undo_stage_hunk() end, desc = "Unstage git hunk" },
["gbr"] = { function() require("gitsigns").reset_buffer() end, desc = "Reset git buffer" },
-- ["gd"] = { function() require("gitsigns").diffthis() end, desc = "View git diff" },
-- git-blame
["gbl"] = { "<cmd>GitBlameToggle<cr>", desc = "Toggle git blame" },
["gbc"] = { "<cmd>GitBlameCopyFileURL<cr>", desc = "Copy current line remote url to clipboard" },
-- docs
-- ["ng"] = { "<cmd>lua require('neogen').generate()<cr>", noremap = true },
["<leader>dd"] = { "<cmd>DogeGenerate<cr>", desc = "Generate documentation template" },
-- code runner
["<leader>r"] = { "<cmd>SnipRun<cr>" },
-- lsp
-- ["gD"] = { "<CMD>Glance definitions<CR>", desc = "Peek definitions" },
-- ["gR"] = { "<CMD>Glance references<CR>", desc = "Peek references" },
-- ["gY"] = { "<CMD>Glance type_definitions<CR>", desc = "Peek type definitions" },
-- ["gM"] = { "<CMD>Glance implementations<CR>", desc = "Peek implementations" },
["gpd"] = { "<CMD>lua require('goto-preview').goto_preview_definition()<CR>", desc = "Preview definitions" },
["gpr"] = { "<CMD>lua require('goto-preview').goto_preview_references()<CR>", desc = "Preview references" },
["gpt"] = {
"<CMD>lua require('goto-preview').goto_preview_type_definition()<CR>",
desc = "Preview type definitions",
},
["gpi"] = { "<CMD>lua require('goto-preview').goto_preview_implementation()<CR>", desc = "Preview implementations" },
["gpc"] = { "<CMD>lua require('goto-preview').close_all_win()<CR>", desc = "close preview windows" },
-- neoclip
["<leader>nc"] = { "<cmd>Telescope neoclip<CR>", desc = "Show neoclip registers" },
-- telescope
-- ["<leader>tc"] = { "<cmd> Cheatsheet <CR>", desc = "Show cheatsheet" },
["<leader><leader>"] = {
"<Cmd>lua require('telescope').extensions.frecency.frecency()<CR>",
noremap = true,
silent = true,
},
["<leader>td"] = { "<cmd> TodoTelescope <CR>", desc = "Show todo items" },
["<leader>pj"] = { "<cmd> Telescope project <CR>", desc = "Show projects" },
["<leader>ma"] = {
function() require("telescope").extensions.vim_bookmarks.all() end,
desc = "Show all bookmarks",
},
["<leader>mc"] = {
function() require("telescope").extensions.vim_bookmarks.current_file() end,
desc = "Show current file bookmarks",
},
["<leader>tt"] = { "<cmd> Telescope colorscheme <CR>", desc = "Show colorscheme picker" },
["<leader>fs"] = {
"<cmd>lua require 'telescope'.extensions.file_browser.file_browser()<CR>",
desc = "Telescope file browser",
},
["<leader>fw"] = {
"<cmd>lua require 'telescope'.extensions.live_grep_args.live_grep_args()<CR>",
desc = "Search word with args",
},
["<leader>fd"] = {
function() require("telescope.builtin").lsp_document_symbols() end,
desc = "Find symbols in current file",
},
["<leader>fb"] = {
function()
require("telescope.builtin").buffers {
sort_mru = true,
ignore_current_buffer = true,
}
end,
desc = "Find buffers in mru order",
},
["<leader>ss"] = {
function() require("telescope.builtin").grep_string() end,
desc = "Search current word on cursor",
},
["<leader>;"] = {
function() require("telescope.builtin").current_buffer_fuzzy_find() end,
desc = "Fuzzy find lines",
},
},
v = {
[";"] = { ":", nowait = true },
-- [";"] = { "<cmd>FineCmdline<cr>", nowait = true, desc = "Floating cmd input" },
["J"] = { ":move '>+1<CR>gv-gv", desc = "Move lines of code up" },
["K"] = { ":move '<-2<CR>gv-gv", desc = "Move lines of code down" },
-- code runner
["<leader>r"] = { "<cmd>SnipRun<cr>" },
-- gitsigns
["ghr"] = { function() require("gitsigns").reset_hunk() end, desc = "Reset git hunk" },
["ghs"] = { function() require("gitsigns").stage_hunk() end, desc = "Stage git hunk" },
},
i = {
["<C-h>"] = { "<ESC>I", desc = "Insert to the first char of current line" },
["<C-l>"] = { "<ESC>A", desc = "Insert to the last char of current line" },
},
t = {
["<A-n>"] = { "<C-\\><C-n>", desc = "Terminal normal mode" },
-- resize
["<A-l>"] = { "<C-\\><C-n>:vertical resize +5<CR>" },
["<A-h>"] = { "<C-\\><C-n>:vertical resize -5<CR>" },
["<A-j>"] = { "<C-\\><C-n>:resize -5<CR>" },
["<A-k>"] = { "<C-\\><C-n>:resize +5<CR>" },
-- toggle
["<A-o>"] = { "<cmd>ToggleTerm direction=float<cr>", desc = "toggle floating terminal" },
["<A-H>"] = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", desc = "toggle horizontal terminal" },
["<A-V>"] = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", desc = "toggle vertical terminal" },
},
}