-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathkeybindings.lua
469 lines (452 loc) Β· 20 KB
/
keybindings.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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
local M = {}
-- HACK: for some reason, the alt keybindings are not working in my wezterm
M.set_wezterm_keybindings = function()
lvim.keys.insert_mode["Γ₯"] = lvim.keys.insert_mode["<A-a>"]
lvim.keys.insert_mode["Γ"] = lvim.keys.insert_mode["<A-s>"]
lvim.keys.insert_mode["Β΄"] = lvim.keys.insert_mode["<A-e>"]
lvim.keys.insert_mode["β"] = lvim.keys.insert_mode["<A-j>"]
lvim.keys.insert_mode["Λ"] = lvim.keys.insert_mode["<A-k>"]
lvim.keys.normal_mode["Γ₯"] = lvim.keys.normal_mode["<A-a>"]
lvim.keys.normal_mode["β"] = lvim.keys.normal_mode["<A-x>"]
lvim.keys.visual_mode["Γ₯"] = lvim.keys.visual_mode["<A-a>"]
lvim.keys.visual_mode["β"] = lvim.keys.visual_mode["<A-x>"]
end
M.set_terminal_keymaps = function()
local opts = { noremap = true }
vim.api.nvim_buf_set_keymap(0, "t", "<esc>", [[<C-\><C-n>]], opts)
vim.api.nvim_buf_set_keymap(0, "t", "<C-h>", [[<C-\><C-n><C-W>h]], opts)
vim.api.nvim_buf_set_keymap(0, "t", "<C-j>", [[<C-\><C-n><C-W>j]], opts)
vim.api.nvim_buf_set_keymap(0, "t", "<C-k>", [[<C-\><C-n><C-W>k]], opts)
vim.api.nvim_buf_set_keymap(0, "t", "<C-l>", [[<C-\><C-n><C-W>l]], opts)
end
M.set_hop_keymaps = function()
local opts = { noremap = true, silent = true }
vim.api.nvim_set_keymap("n", "s", ":HopChar2MW<cr>", opts)
vim.api.nvim_set_keymap("n", "S", ":HopWordMW<cr>", opts)
vim.api.nvim_set_keymap(
"n",
"f",
"<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true })<cr>",
{}
)
vim.api.nvim_set_keymap(
"n",
"F",
"<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true })<cr>",
{}
)
vim.api.nvim_set_keymap(
"o",
"f",
"<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true, inclusive_jump = true })<cr>",
{}
)
vim.api.nvim_set_keymap(
"o",
"F",
"<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true, inclusive_jump = true })<cr>",
{}
)
vim.api.nvim_set_keymap(
"",
"t",
"<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true, hint_offset = -1 })<cr>",
{}
)
vim.api.nvim_set_keymap(
"",
"T",
"<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true, hint_offset = -1 })<cr>",
{}
)
end
M.set_hlslens_keymaps = function()
local opts = { noremap = true, silent = true }
vim.api.nvim_set_keymap(
"n",
"n",
"<Cmd>execute('normal! ' . v:count1 . 'n')<CR><Cmd>lua require('hlslens').start()<CR>",
opts
)
vim.api.nvim_set_keymap(
"n",
"N",
"<Cmd>execute('normal! ' . v:count1 . 'N')<CR><Cmd>lua require('hlslens').start()<CR>",
opts
)
vim.api.nvim_set_keymap("n", "*", "*<Cmd>lua require('hlslens').start()<CR>", opts)
vim.api.nvim_set_keymap("n", "#", "#<Cmd>lua require('hlslens').start()<CR>", opts)
vim.api.nvim_set_keymap("n", "g*", "g*<Cmd>lua require('hlslens').start()<CR>", opts)
vim.api.nvim_set_keymap("n", "g#", "g#<Cmd>lua require('hlslens').start()<CR>", opts)
end
local function set_bufferline_keymaps()
lvim.keys.normal_mode["<S-x>"] = "<Cmd>lua require('user.bufferline').delete_buffer()<CR>"
lvim.keys.normal_mode["<S-l>"] = "<Cmd>BufferLineCycleNext<CR>"
lvim.keys.normal_mode["<S-h>"] = "<Cmd>BufferLineCyclePrev<CR>"
lvim.keys.normal_mode["[b"] = "<Cmd>BufferLineMoveNext<CR>"
lvim.keys.normal_mode["]b"] = "<Cmd>BufferLineMovePrev<CR>"
lvim.builtin.which_key.mappings["c"] = {}
lvim.builtin.which_key.mappings.b = {
name = "ο©―Buffer",
["1"] = { "<Cmd>BufferLineGoToBuffer 1<CR>", "goto 1" },
["2"] = { "<Cmd>BufferLineGoToBuffer 2<CR>", "goto 2" },
["3"] = { "<Cmd>BufferLineGoToBuffer 3<CR>", "goto 3" },
["4"] = { "<Cmd>BufferLineGoToBuffer 4<CR>", "goto 4" },
["5"] = { "<Cmd>BufferLineGoToBuffer 5<CR>", "goto 5" },
["6"] = { "<Cmd>BufferLineGoToBuffer 6<CR>", "goto 6" },
["7"] = { "<Cmd>BufferLineGoToBuffer 7<CR>", "goto 7" },
["8"] = { "<Cmd>BufferLineGoToBuffer 8<CR>", "goto 8" },
["9"] = { "<Cmd>BufferLineGoToBuffer 9<CR>", "goto 9" },
c = { "<Cmd>BufferLinePickClose<CR>", "delete buffer" },
p = { "<Cmd>BufferLineTogglePin<CR>", "toggle pin" },
s = { "<Cmd>BufferLinePick<CR>", "pick buffer" },
t = { "<Cmd>BufferLineGroupToggle docs<CR>", "toggle groups" },
f = { "<cmd>Telescope buffers<cr>", "Find" },
b = { "<cmd>b#<cr>", "Previous" },
h = { "<cmd>BufferLineCloseLeft<cr>", "Close all to the left" },
l = {
"<cmd>BufferLineCloseRight<cr>",
"Close all to the right",
},
D = {
"<cmd>BufferLineSortByDirectory<cr>",
"Sort by directory",
},
L = {
"<cmd>BufferLineSortByExtension<cr>",
"Sort by language",
},
}
end
local function set_harpoon_keymaps()
lvim.keys.normal_mode["<C-Space>"] = "<cmd>lua require('harpoon.cmd-ui').toggle_quick_menu()<CR>"
lvim.keys.normal_mode["tu"] = "<cmd>lua require('harpoon.term').gotoTerminal(1)<CR>"
lvim.keys.normal_mode["te"] = "<cmd>lua require('harpoon.term').gotoTerminal(2)<CR>"
lvim.keys.normal_mode["cu"] = "<cmd>lua require('harpoon.term').sendCommand(1, 1)<CR>"
lvim.keys.normal_mode["ce"] = "<cmd>lua require('harpoon.term').sendCommand(1, 2)<CR>"
lvim.builtin.which_key.mappings["a"] = { "<cmd>lua require('harpoon.mark').add_file()<CR>", "ο Add Mark" }
lvim.builtin.which_key.mappings["<leader>"] = {
"<cmd>lua require('harpoon.ui').toggle_quick_menu()<CR>",
"ο’ Harpoon",
}
local whk_status, whk = pcall(require, "which-key")
if not whk_status then
return
end
whk.register {
["<leader>1"] = { "<CMD>lua require('harpoon.ui').nav_file(1)<CR>", "ο’£ goto1" },
["<leader>2"] = { "<CMD>lua require('harpoon.ui').nav_file(2)<CR>", "ο’¦ goto2" },
["<leader>3"] = { "<CMD>lua require('harpoon.ui').nav_file(3)<CR>", "ο’© goto3" },
["<leader>4"] = { "<CMD>lua require('harpoon.ui').nav_file(4)<CR>", "ο’¬ goto4" },
}
end
M.set_task_runner_keymaps = function()
if lvim.builtin.task_runner == "async_tasks" then
lvim.builtin.which_key.mappings["m"] = {
name = "ο Make",
f = { "<cmd>AsyncTask file-build<cr>", "File" },
p = { "<cmd>AsyncTask project-build<cr>", "Project" },
e = { "<cmd>AsyncTaskEdit<cr>", "Edit" },
l = { "<cmd>AsyncTaskList<cr>", "List" },
}
lvim.builtin.which_key.mappings["r"] = {
name = "ο Run",
f = { "<cmd>AsyncTask file-run<cr>", "File" },
p = { "<cmd>AsyncTask project-run<cr>", "Project" },
}
elseif lvim.builtin.task_runner == "overseer" then
lvim.builtin.which_key.mappings["m"] = {
name = "ο Tasks",
l = { "<cmd>OverseerLoadBundle<CR>", "Load Bundle" },
s = { "<cmd>OverseerSaveBundle<CR>", "Save Bundle" },
n = { "<cmd>OverseerBuild<CR>", "New Task" },
q = { "<cmd>OverseerQuickAction<CR>", "Quick Action" },
f = { "<cmd>OverseerTaskAction<CR>", "Task Action" },
t = { "<cmd>OverseerToggle<cr>", "Toggle Output" },
}
lvim.builtin.which_key.mappings["r"] = {
name = "ο Run",
f = { "<cmd>OverseerRun<cr>", "Run" },
p = { "<cmd>OverseerRunCmd<cr>", "Run with Cmd" },
t = { "<cmd>OverseerToggle<cr>", "Toggle" },
}
else
lvim.builtin.which_key.mappings["m"] = "Make"
lvim.builtin.which_key.mappings["r"] = "Run"
require("user.autocommands").make_run()
end
end
M.set_lsp_lines_keymap = function()
lvim.builtin.which_key.mappings["v"] = {
"<cmd>lua require('lsp_lines').toggle()<CR>",
"ο§ΌLSP Lines",
}
end
M.config = function()
-- Additional keybindings
-- =========================================
lvim.keys.normal_mode["<CR>"] = {
"<cmd>lua require('user.neovim').maximize_current_split()<CR>",
{ noremap = true, silent = true, nowait = true },
}
lvim.keys.insert_mode["<A-a>"] = "<ESC>ggVG<CR>"
lvim.keys.insert_mode["jk"] = "<ESC>:w<CR>"
if lvim.builtin.noice.active then
lvim.keys.insert_mode["<C-s>"] = function()
local params = vim.lsp.util.make_position_params(0, "utf-16")
vim.lsp.buf_request(0, "textDocument/signatureHelp", params, function(err, result, ctx)
require("noice.lsp").signature(err, result, ctx, {
trigger = true,
})
end)
end
end
lvim.keys.insert_mode["<A-s>"] =
"<cmd>lua require('telescope').extensions.luasnip.luasnip(require('telescope.themes').get_cursor({}))<CR>"
lvim.keys.command_mode["w!!"] = "execute 'silent! write !sudo tee % >/dev/null' <bar> edit!"
lvim.keys.normal_mode["]d"] = "<cmd>lua vim.diagnostic.goto_next()<cr>"
lvim.keys.normal_mode["[d"] = "<cmd>lua vim.diagnostic.goto_prev()<cr>"
lvim.keys.normal_mode["<A-a>"] = "<C-a>"
lvim.keys.normal_mode["<A-x>"] = "<C-x>"
lvim.keys.normal_mode["<C-,>"] = "<cmd>lua require('neogen').jump_next()<CR>"
lvim.keys.normal_mode["<C-n>i"] = { "<C-i>", { noremap = true } }
if vim.fn.has "mac" == 1 then
lvim.keys.normal_mode["gx"] =
[[<cmd>lua os.execute("open " .. vim.fn.shellescape(vim.fn.expand "<cWORD>")); vim.cmd "redraw!"<cr>]]
elseif vim.fn.has "linux" then
lvim.keys.normal_mode["gx"] =
[[<cmd>lua os.execute("xdg-open " .. vim.fn.shellescape(vim.fn.expand "<cWORD>")); vim.cmd "redraw!"<cr>]]
end
if lvim.builtin.bufferline.active then
set_bufferline_keymaps()
end
if lvim.builtin.sidebar.active then
lvim.keys.normal_mode["E"] = ":SidebarNvimToggle<cr>"
end
lvim.keys.normal_mode["<esc><esc>"] = "<cmd>nohlsearch<cr>"
lvim.keys.normal_mode["Y"] = "y$"
lvim.keys.normal_mode["gv"] =
"<cmd>vsplit | lua vim.lsp.buf.definition({on_list = function(items) vim.fn.setqflist({}, 'r', items) vim.cmd('cfirst') end})<cr>"
if lvim.builtin.harpoon.active then
set_harpoon_keymaps()
end
lvim.keys.visual_mode["<A-a>"] = "<C-a>"
lvim.keys.visual_mode["<A-x>"] = "<C-x>"
lvim.keys.visual_mode["p"] = [["_dP]]
lvim.keys.visual_mode["ga"] = "<esc><Cmd>lua vim.lsp.buf.range_code_action()<CR>"
lvim.keys.visual_mode["<leader>st"] = "<Cmd>lua require('user.telescope').grep_string_visual()<CR>"
-- WhichKey keybindings
-- =========================================
M.set_task_runner_keymaps()
local status_ok_comment, cmt = pcall(require, "Comment.api")
if status_ok_comment and cmt["toggle"] ~= nil then
lvim.builtin.which_key.mappings["/"] = {
"<cmd>lua require('Comment.api').toggle.linewise.current()<CR>",
"ο Comment",
}
else
lvim.builtin.which_key.mappings["/"] = { "<Plug>(comment_toggle_linewise_current)", "ο» Comment" }
end
lvim.builtin.which_key.mappings[";"] = { "<cmd>Alpha<CR>", "ο©Dashboard" }
if lvim.builtin.dap.active then
lvim.builtin.which_key.mappings["de"] = { "<cmd>lua require('dapui').eval()<cr>", "Eval" }
lvim.builtin.which_key.mappings["dU"] = { "<cmd>lua require('dapui').toggle()<cr>", "Toggle UI" }
end
if lvim.builtin.fancy_diff.active then
lvim.builtin.which_key.mappings["gd"] = { "<cmd>DiffviewOpen<cr>", "diffview: diff HEAD" }
lvim.builtin.which_key.mappings["gh"] = { "<cmd>DiffviewFileHistory<cr>", "diffview: filehistory" }
else
lvim.builtin.which_key.mappings["gh"] = { "<cmd>Telescope git_bcommits<cr>", "file history" }
end
if lvim.builtin.cheat.active then
lvim.builtin.which_key.mappings["?"] = { "<cmd>Cheat<CR>", "ξ€ Cheat.sh" }
end
if lvim.builtin.lsp_lines then
M.set_lsp_lines_keymap()
end
if lvim.builtin.tree_provider == "neo-tree" then
lvim.builtin.which_key.mappings["e"] = { ":NeoTreeRevealToggle<CR>", "ο΅ Explorer" }
end
lvim.builtin.which_key.mappings["F"] = {
name = "ο« Find",
b = { "<cmd>lua require('user.telescope').builtin()<cr>", "Builtin" },
f = { "<cmd>lua require('user.telescope').curbuf()<cr>", "Current Buffer" },
g = { "<cmd>lua require('user.telescope').git_files()<cr>", "Git Files" },
i = { "<cmd>lua require('user.telescope').installed_plugins()<cr>", "Installed Plugins" },
l = {
"<cmd>lua require('telescope.builtin').resume()<cr>",
"Last Search",
},
p = { "<cmd>lua require('user.telescope').project_search()<cr>", "Project" },
s = { "<cmd>lua require('user.telescope').git_status()<cr>", "Git Status" },
z = { "<cmd>lua require('user.telescope').search_only_certain_files()<cr>", "Certain Filetype" },
}
if lvim.builtin.legendary.active then
lvim.builtin.which_key.mappings["C"] =
{ "<cmd>lua require('legendary').find('commands')<cr>", "ξ« Command Palette" }
lvim.keys.normal_mode["<c-P>"] = "<cmd>lua require('legendary').find()<cr>"
end
if lvim.builtin.file_browser.active then
lvim.builtin.which_key.mappings["se"] = { "<cmd>Telescope file_browser<cr>", "File Browser" }
end
lvim.builtin.which_key.mappings["H"] = "ο Help"
lvim.builtin.which_key.mappings["h"] = { "<cmd>nohlsearch<CR>", "ο» No Highlight" }
lvim.builtin.which_key.mappings.g.name = "ο Git"
if lvim.builtin.inlay_hints.active then
lvim.builtin.which_key.mappings["I"] = { "<cmd>lua require('lsp-inlayhints').toggle()<cr>", "ξ΅ Toggle Inlay" }
end
lvim.builtin.which_key.mappings.l.name = "ο³ LSP"
lvim.builtin.which_key.mappings["f"] = {
require("user.telescope").find_project_files,
"ο Find File",
}
local ok, _ = pcall(require, "vim.diagnostic")
if ok then
lvim.builtin.which_key.mappings["l"]["j"] = {
"<cmd>lua vim.diagnostic.goto_next({float = {border = 'rounded', focusable = false, source = 'always'}, severity = {min = vim.diagnostic.severity.WARN}})<cr>",
"Next Diagnostic",
}
lvim.builtin.which_key.mappings["l"]["k"] = {
"<cmd>lua vim.diagnostic.goto_prev({float = {border = 'rounded', focusable = false, source = 'always'}, severity = {min = vim.diagnostic.severity.WARN}})<cr>",
"Prev Diagnostic",
}
end
if status_ok_comment and cmt["toggle"] ~= nil then
lvim.builtin.which_key.vmappings["/"] =
{ "<ESC><CMD>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>", "Comment" }
end
if lvim.builtin.noice.active then
lvim.builtin.which_key.mappings["l"]["r"] = { ":IncRename ", "Rename" }
lvim.builtin.which_key.mappings["l"]["R"] = {
function()
return ":IncRename " .. vim.fn.expand "<cword>"
end,
"Rename keep",
expr = true,
}
else
lvim.builtin.which_key.vmappings["l"] = {
name = "+Lsp",
r = { "<ESC><CMD>lua vim.lsp.buf.rename()<CR>", "Rename" },
}
end
lvim.builtin.which_key.mappings["lp"] = {
name = "Peek",
d = { "<cmd>lua require('user.peek').Peek('definition')<cr>", "Definition" },
t = { "<cmd>lua require('user.peek').Peek('typeDefinition')<cr>", "Type Definition" },
i = { "<cmd>lua require('user.peek').Peek('implementation')<cr>", "Implementation" },
}
lvim.builtin.which_key.mappings["lh"] = {
"<cmd>hi LspReferenceRead cterm=bold ctermbg=red guibg=#24283b<cr><cmd>hi LspReferenceText cterm=bold ctermbg=red guibg=#24283b<cr><cmd>hi LspReferenceWrite cterm=bold ctermbg=red guibg=#24283b<cr>",
"Clear HL",
}
if lvim.builtin.persistence then
lvim.builtin.which_key.mappings["q"] = {
name = "ο
Quit",
d = { "<cmd>lua require('persistence').stop()<cr> | :qa!<cr>", "Quit without saving session" },
l = { "<cmd>lua require('persistence').load(last=true)<cr>", "Restore last session" },
s = { "<cmd>lua require('persistence').load()<cr>", "Restore for current dir" },
q = { "<cmd>lua require('lvim.utils.functions').smart_quit()<CR>", "Quit" },
}
end
lvim.builtin.which_key.mappings["n"] = {
name = "ξ Neogen",
c = { "<cmd>lua require('neogen').generate({ type = 'class'})<CR>", "Class Documentation" },
f = { "<cmd>lua require('neogen').generate({ type = 'func'})<CR>", "Function Documentation" },
t = { "<cmd>lua require('neogen').generate({ type = 'type'})<CR>", "Type Documentation" },
F = { "<cmd>lua require('neogen').generate({ type = 'file'})<CR>", "File Documentation" },
}
lvim.builtin.which_key.mappings["N"] = { "<cmd>Telescope file_create<CR>", "ο Create new file" }
if lvim.builtin.tag_provider == "symbols-outline" then
lvim.builtin.which_key.mappings["o"] = { "<cmd>SymbolsOutline<cr>", "ξ Symbol Outline" }
elseif lvim.builtin.tag_provider == "vista" then
lvim.builtin.which_key.mappings["o"] = { "<cmd>Vista!!<cr>", "Vista" }
end
lvim.builtin.which_key.mappings.L.name = "ο LunarVim"
lvim.builtin.which_key.mappings.p.name = "ο£ Packer"
lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope projects<CR>", "ξ Projects" }
lvim.builtin.which_key.mappings["R"] = {
name = "οΉ Replace",
f = { "<cmd>lua require('spectre').open_file_search()<cr>", "Current Buffer" },
p = { "<cmd>lua require('spectre').open()<cr>", "Project" },
w = { "<cmd>lua require('spectre').open_visual({select_word=true})<cr>", "Replace Word" },
s = {
function()
require("ssr").open()
end,
"Structural replace",
},
}
lvim.builtin.which_key.mappings.s.name = "ο Search"
lvim.builtin.which_key.mappings["ss"] = {
"<cmd>lua require('telescope').extensions.live_grep_args.live_grep_args()<cr>",
"String",
}
if lvim.builtin.test_runner.active then
if lvim.builtin.test_runner.runner == "neotest" then
lvim.builtin.which_key.mappings["t"] = {
name = "ο§ Test",
f = {
"<cmd>lua require('neotest').run.run({vim.fn.expand('%'), env=require('user.ntest').get_env()})<cr>",
"File",
},
o = { "<cmd>lua require('neotest').output.open({ enter = true, short = false })<cr>", "Output" },
r = { "<cmd>lua require('neotest').run.run({env=require('user.ntest').get_env()})<cr>", "Run" },
a = { "<cmd>lua require('user.ntest').run_all()<cr>", "Run All" },
c = { "<cmd>lua require('user.ntest').cancel()<cr>", "Cancel" },
R = { "<cmd>lua require('user.ntest').run_file_sync()<cr>", "Run Async" },
s = { "<cmd>lua require('neotest').summary.toggle()<cr>", "Summary" },
n = { "<cmd>lua require('neotest').jump.next({ status = 'failed' })<cr>", "jump to next failed" },
p = { "<cmd>lua require('neotest').jump.prev({ status = 'failed' })<cr>", "jump to previous failed" },
d = { "<cmd>lua require('neotest').run.run({ strategy = 'dap' })<cr>", "Dap Run" },
x = { "<cmd>lua require('neotest').run.stop()<cr>", "Stop" },
w = { "<cmd>lua require('neotest').watch.watch()<cr>", "Watch" },
}
else
lvim.builtin.which_key.mappings["t"] = {
name = "ο§ Test",
f = { "<cmd>Ultest<cr>", "File" },
n = { "<cmd>UltestNearest<cr>", "Nearest" },
s = { "<cmd>UltestSummary<cr>", "Summary" },
}
end
end
lvim.builtin.which_key.mappings["T"] = {
name = "ο¨ͺTrouble",
d = { "<cmd>Trouble document_diagnostics<cr>", "Diagnosticss" },
f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
l = { "<cmd>Trouble loclist<cr>", "LocationList" },
q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
r = { "<cmd>Trouble lsp_references<cr>", "References" },
t = { "<cmd>TodoLocList <cr>", "Todo" },
w = { "<cmd>Trouble workspace_diagnostics<cr>", "Diagnosticss" },
}
lvim.builtin.which_key.mappings["z"] = { "<cmd>ZenMode<cr>", "ξΈ Zen" }
lvim.builtin.which_key.mappings["w"] = { "<cmd>w!<CR>", "ο Save" }
lvim.builtin.which_key.vmappings["g"] = {
name = "ο Git",
s = { "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk" },
}
lvim.builtin.which_key.vmappings["r"] = {
function()
require("ssr").open()
end,
"Structural replace",
}
-- My wezterm is weird
-- =========================================
local user = vim.env.USER
if user and user == "abz" then
M.set_wezterm_keybindings()
end
-- Navigate merge conflict markers
local whk_status, whk = pcall(require, "which-key")
if not whk_status then
return
end
whk.register {
["]n"] = { "[[:call search('^(@@ .* @@|[<=>|]{7}[<=>|]@!)', 'W')<cr>]]", "next merge conflict" },
["[n"] = { "[[:call search('^(@@ .* @@|[<=>|]{7}[<=>|]@!)', 'bW')<cr>]]", "prev merge conflict" },
}
end
return M