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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
|
---@type MappingsTable
local M = {}
local opts = { noremap = false, expr = true, buffer = true }
M.disabled = {
n = {
["<A-i>"] = "",
["<C-a>"] = "",
["<C-b>"] = "",
["<C-c>"] = "",
["<leader>b"] = "",
["<leader>ca"] = "",
["<leader>fm"] = "",
["<leader>n"] = "",
["<leader>rn"] = "",
["<leader>td"] = "",
["<tab>"] = "",
["<S-tab>"] = "",
},
t = {
["<A-i>"] = "",
},
}
M.general = {
i = {
-- ESC
["jk"] = { "<ESC>", "Exit Insert Mode" },
-- Navigation
["<C-i>"] = { "<ESC>^i", "Beginning Of Line" },
-- Lines
["<C-a>"] = { "<ESC>o", "Next Line", opts = { nowait = true } },
["<C-b>"] = { "<ESC>O", "Previous Line", opts = { nowait = true } },
["<leader>ln"] = { "<cmd> set nu! <CR>", "Toggle Line Number" },
["<leader>lrn"] = { "<cmd> set rnu! <CR>", "Toggle Relative Number" },
},
n = {
-- General
["<C-c>"] = { ":", "Enter Command Mode", opts = { nowait = true } },
-- ["x"] = { "_x", "No Register x" },
["Q"] = { "<nop>", "Nothing" },
-- Copy & Paste
["<leader>cpa"] = { "<cmd> %y+ <CR>", "Copy Whole File" },
["<leader>y"] = { '"+y', "yank in Vim" },
["<leader>Y"] = { '"+Y', "Yank in Clipboard" },
-- ["<leader>s"] = { [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]], "Replace char on cursor" },
-- Formatting
["<leader>lfm"] = {
function()
vim.lsp.buf.format { async = true }
end,
"LSP Formatting",
},
-- Line
-- ["<C-a>"] = { "o<ESC>", "Blank line after", opts = { nowait = true } },
-- ["<C-b>"] = { "O<ESC>", "Blank line before", opts = { nowait = true } },
-- Navigation
["J"] = { "mzJ`z", "Join A Line To Pre-line" },
["n"] = { "nzzzv", "Down Search with Mid Cursor" },
["N"] = { "Nzzzv", "Up Search with Mid Cursor" },
["<C-d>"] = { "<C-d>zz", "Jump 1/2 Page with Mid Cursor" },
["<C-u>"] = { "<C-u>zz", "Up 1/2 Page with Mid Cursor" },
["<C-f>"] = { "<C-f>zz", "Page Down with Mid Cursor" },
["<C-b>"] = { "<C-b>zz", "Page Up with Mid Cursor" },
-- ["<C-k>"] = { "<cmd>cnext<CR>zz", "reset cursor" },
-- ["<C-j>"] = { "<cmd>cprev<CR>zz", "reset cursor" },
["<C-h>"] = { "<cmd> TmuxNavigateLeft <CR>", "Window Left" },
["<C-l>"] = { "<cmd> TmuxNavigateRight <CR>", "Window Right" },
["<C-j>"] = { "<cmd> TmuxNavigateDown <CR>", "Window Down" },
["<C-k>"] = { "<cmd> TmuxNavigateUp <CR>", "Window Up" },
["<leader>tg"] = {
function()
require("base46").toggle_theme()
end,
"Theme Toggle",
},
-- New Buffer
["<leader>bf"] = { "<cmd> enew <CR>", "New Buffer" },
-- Split
["<leader>sv"] = { "<C-w>v", "Split Vertically" },
["<leader>sh"] = { "<C-w>h", "Split Horizontally" },
["<leader>se"] = { "<C-w>=", "Equal Width" },
["<leader>sx"] = { "<cmd> close <CR>", "Close Split Window" },
},
v = {
[";"] = { ":", "Enter Command Mode", opts = { nowait = true } },
[">"] = { ">gv", "Indent" },
["<C-n>"] = { "<ESC> ", "Exit Visual Mode" },
["J"] = { ":m '>+1<CR>gv=gv", "Move A Line To Bottom" },
["K"] = { ":m '<-2<CR>gv=gv", "Move A Line To Up" },
["<leader>y"] = { '"+y', "yank in Vim" },
},
}
-- more keybinds!
M.browse = {
n = {
["<leader>bs"] = {
function()
require("browse").input_search()
end,
"Search Bookmarks",
},
["<leader>bm"] = {
function()
require("browse").open_bookmarks()
end,
"Browse Bookmarks",
},
["<leader>bb"] = {
function()
require("browse").browse()
end,
"Browse Bookmarks",
},
["<leader>bd"] = {
function()
require("browse.devdocs").search()
end,
"Search Devdocs",
},
["<leader>bn"] = {
function()
require("browse.mdn").search()
end,
"Search MDN",
},
},
}
M.chatgpt = {
n = {
["<leader>cg<CR>"] = { "<cmd> ChatGPT <CR>", "ChatGPT" },
["<leader>cgc"] = { "<cmd> ChatGPTCompleteCode <CR>", "ChatGPT Complete Code" },
["<leader>cgt"] = { "<cmd> ChatGPTRun add_tests <CR>", "ChatGPT Add Test" },
["<leader>cgf"] = { "<cmd> ChatGPTRun fix_bugs <CR>", "ChatGPT Fix Bugs" },
["<leader>cga"] = { "<cmd> ChatGPTActAs <CR>", "ChatGPT Act As" },
["<leader>cgi"] = { "<cmd> ChatGPTEditWithInstructions <CR>", "ChatGPT Edit" },
},
v = {
["<leader>cge"] = { "<cmd> ChatGPTRun explain_code <CR>", "ChatGPT Explain Code" },
},
}
M.dadbod = {
n = {
["<leader>db"] = { "<cmd> DBUI <CR>", "DB UI" },
["<leader>du"] = { "<cmd> DBUIToggle <CR>", "Toggle UI" },
["<leader>da"] = { "<cmd> DBUIAddConnection <CR>", "Add Connection" },
["<leader>df"] = { "<cmd> DBUIFindBuffer <CR>", "Find buffer" },
["<leader>dr"] = { "<cmd> DBUIRenameBuffer <CR>", "Rename buffer" },
["<leader>dl"] = { "<cmd> DBUILastQueryInfo <CR>", "Last query info" },
},
}
M.gitsigns = {
n = {
["<leader>gd"] = {
function()
require("gitsigns").toggle_deleted()
end,
"Toggle Deleted",
},
},
}
M.harpoon = {
n = {
["<leader>a"] = {
function()
require("harpoon.mark").add_file()
end,
"Harpoon Add File",
},
["<leader>ta"] = { "<cmd> Telescope harpoon marks <CR>", "Toggle Quick Menu" },
["<leader><tab>"] = {
function()
require("harpoon.ui").toggle_quick_menu()
end,
"Harpoon Menu",
},
["<leader>1"] = {
function()
require("harpoon.ui").nav_file(1)
end,
"Navigate to File 1",
},
["<leader>2"] = {
function()
require("harpoon.ui").nav_file(2)
end,
"Navigate to File 2",
},
["<leader>3"] = {
function()
require("harpoon.ui").nav_file(3)
end,
"Navigate to File 3",
},
["<leader>4"] = {
function()
require("harpoon.ui").nav_file(4)
end,
"Navigate to File 4",
},
},
}
M.iron = {
n = {
["<leader>ir"] = { "<cmd> IronRepl <CR>", "REPL" },
["<leader>iS"] = { "<cmd> IronRestart <CR>", "Restart" },
["<leader>iF"] = { "<cmd> IronFocus <CR>", "Focus" },
["<leader>iH"] = { "<cmd> IronHide <CR>", "Hide" },
["<leader>ism"] = {
function()
require("iron.core").run_motion "send_motion"
end,
"Send Motion",
},
["<leader>isl"] = {
function()
require("iron.core").send_line()
end,
"Send Line",
},
["<leader>ist"] = {
function()
require("iron.core").send_until_cursor()
end,
"Send Until Cursor",
},
["<leader>isf"] = {
function()
require("iron.core").send_file()
end,
"Send File",
},
["<leader>i<cr>"] = {
function()
require("iron.core").send(nil, string.char(13))
end,
"ENTER",
},
["<leader>ii"] = {
function()
require("iron.core").send(nil, string.char(03))
end,
"Interrupt",
},
["<leader>id"] = {
function()
require("iron.core").close_repl()
end,
"Close REPL",
},
["<leader>ic"] = {
function()
require("iron.core").send(nil, string.char(12))
end,
"Clear",
},
["<leader>ims"] = {
function()
require("iron.core").send_mark()
end,
"Send Mark",
},
["<leader>imm"] = {
function()
require("iron.core").run_motion "mark_motion"
end,
"Mark Motion",
},
["<leader>imr"] = {
function()
require("iron.marks").drop_last()
end,
"Remove Mark",
},
-- ["<leader>iar"] = {
-- function() end,
-- "+ REPL",
-- },
-- ["<leader>iam"] = {
-- function() end,
-- "+ Mark",
-- },
-- cell
["<leader>ca"] = {
function()
require("custom.configs.cell_marker").insert_cell_after()
end,
"Insert Cell After",
},
["<leader>cb"] = {
function()
require("custom.configs.cell_marker").insert_cell_before()
end,
"Insert Cell Before",
},
["<leader>cm"] = {
function()
require("custom.configs.cell_marker").insert_markdown_cell()
end,
"Insert Markdown Cell",
},
["<leader>cd"] = {
function()
require("custom.configs.cell_marker").delete_cell()
end,
"Delete Cell",
},
["<leader>cj"] = {
function()
require("custom.configs.cell_marker").navigate_cell()
end,
"Next Cell",
},
["<leader>ck"] = {
function()
require("custom.configs.cell_marker").navigate_cell(true)
end,
"Previous Cell",
},
["<leader>cr"] = {
function()
require("custom.configs.cell_marker").execute_cell()
end,
"Cell Run",
},
},
v = {
["<leader>ihc"] = {
function()
require("iron.marks").clear_hl()
end,
"Clear Highlight",
},
["<leader>imv"] = {
function()
require("iron.core").mark_visual()
end,
"Mark Visual",
},
["<leader>is"] = {
function()
require("iron.core").visual_send()
end,
"Send",
},
},
}
M.lspconfig = {
v = {
["<leader>ca"] = {
function()
vim.lsp.buf.code_action()
end,
"LSP code action",
},
},
}
M.markdown = {
n = {
["<leader>mp"] = { "<cmd> MarkdownPreview <CR>", "Markdown Preview" },
["<leader>ms"] = { "<cmd> MarkdownPreviewStop <CR>", "Markdown Stop" },
["<leader>mt"] = { "<cmd> MarkdownPreviewToggle <CR>", "Markdown Toggle" },
},
}
M.media = {
n = {
["<leader>fm"] = { "<cmd> Telescope media_files <CR>", "Media Files" },
},
}
M.nvterm = {
t = {
["<A-t>"] = {
function()
require("nvterm.terminal").toggle "float"
end,
"Toggle Floating Term",
},
},
}
M.playground = {
n = {
["<leader>pg"] = { "<cmd> TSPlaygroundToggle <CR>", "Toggle Playground" },
["<leader>pc"] = { "<cmd> TSHighlightCapturesUnderCurso <CR>", "Highlight Captures" },
["<leader>pn"] = { "<cmd> TSNodeUnderCursor <CR>", "Node Under Cursor" },
},
}
M.portal = {
n = {
["<leader>pj"] = { "<cmd> Portal jumplist backward <CR>", "Portal Jumplist" },
["<leader>ph"] = {
function()
require("portal.builtin").harpoon.tunnel()
end,
"Portal Harpoon",
},
},
}
M.project = {
n = {
["<leader>fp"] = { "<cmd> Telescope projects <CR>", "Find Project" },
},
}
M.refactoring = {
n = {
-- refactoring
["<leader>ri"] = { "<cmd> Refactor inline_var <CR>", "Refactor Inline Var" },
["<leader>rI"] = { "<cmd> Refactor inline_func <CR>", "Refactor Inline Function" },
["<leader>rb"] = { "<cmd> Refactor extract_block <CR>", "Refactor Extract Block" },
["<leader>rbf"] = { "<cmd> Refactor extract_block_to_file <CR>", "Refactor Extrack Block To File" },
},
x = {
-- copy & paste
-- ["<leader>p"] = { '"_dp', "preserve cut" },
-- refactoring
["<leader>re"] = { "<cmd> Refactor extract <CR>", "Refactor Extract" },
["<leader>rf"] = { "<cmd> Refactor extract_to_file <CR>", "Refactor Extract To File" },
["<leader>rv"] = { "<cmd> Refactor extract_var <CR>", "Refactor Extract Var" },
["<leader>ri"] = { "<cmd> Refactor inline_var <CR>", "Refactor Inline Var" },
},
}
M.sniprun = {
n = {
["<leader>sr"] = {
"<cmd>lua require('sniprun').run()<CR>",
"Run Code",
},
["<leader>ss"] = {
"<cmd>lua require('sniprun').reset()<CR>",
"Reset Code",
},
["<leader>sc"] = {
"<cmd>lua require('sniprun').clear_repl()<CR>",
"Clean Repl Meomory",
},
["<leader>sd"] = {
"<cmd>lua require('sniprun.display').close_all()<CR>",
"Close Display",
},
},
v = {
["<C-,>"] = {
"<cmd>lua require('sniprun').run('v')<CR>",
"Run Code",
},
},
}
M.tagbar = {
n = {
["<leader>tb"] = { "<cmd> TagbarToggle <CR>", "Toggle Tagbar" },
},
}
M.telescope = {
n = {
["<leader>u"] = {
function()
require("telescope").extensions.undo.undo()
end,
"Undo Tree",
},
["<leader>fc"] = { "<Cmd> Telescope frecency <CR>", "Frequent Files" },
},
}
M.todo = {
n = {
["<leader>tdo"] = { "<cmd> Todo <CR>", "Todo" },
["<leader>tds"] = { "<cmd> TodoTelescope <CR>", "Todo Telescope" },
["<leader>tdt"] = { "<cmd> TodoTrouble <CR>", "Todo Trouble" },
["<leader>tdl"] = { "<cmd> TodoLocList <CR>", "Todo Loclist" },
["<leader>tdf"] = { "<cmd> TodoQuickFix <CR>", "Todo Fix" },
},
}
M.treesitter = {
n = {
-- ["<leader>tc"] = { "<cmd> TSContextEnable <CR>", "Toggle treesitter context" },
["<leader>gc"] = {
function()
require("treesitter-context").go_to_context()
end,
"Go To Context",
},
},
}
M.trouble = {
n = {
["<leader>trb"] = {
function()
require("trouble").toggle()
end,
"Trouble",
},
["<leader>trw"] = {
function()
require("trouble").toggle "workspace_diagnostics"
end,
"Trouble Workspace Diagnostics",
},
["<leader>trd"] = {
function()
require("trouble").toggle "document_diagnostics"
end,
"Trouble Document Diagnostics",
},
["<leader>trq"] = {
function()
require("trouble").toggle "quickfix"
end,
"Trouble Quickfix",
},
["<leader>trl"] = {
function()
require("trouble").toggle "loclist"
end,
"Trouble Loclist",
},
["gR"] = {
function()
require("trouble").toggle "lsp_references"
end,
"Trouble Lsp References",
},
["<leader>trc"] = {
function()
require("trouble").close()
end,
"Trouble Close",
},
["<leader>tro"] = {
function()
require("trouble").next { skip_groups = true, jump = true }
end,
"Trouble Next",
},
["<leader>tri"] = {
function()
require("trouble").previous { skip_groups = true, jump = true }
end,
"Trouble Previous",
},
["<leader>trf"] = {
function()
require("trouble").first { skip_groups = true, jump = true }
end,
"Trouble First",
},
["<leader>tre"] = {
function()
require("trouble").last { skip_groups = true, jump = true }
end,
"Trouble Last",
},
-- ["<leader>trt"] = {
-- function()
-- require("trouble.providers.telescope").open_with_trouble()
-- end,
-- "Trouble Telescope",
-- },
},
}
M.obsidian = {
i = {
["gf"] = {
function()
require("obsidian").util.gf_passthrough()
end,
"gf",
opts,
},
},
n = {
["gf"] = {
function()
require("obsidian").util.gf_passthrough()
end,
"gf",
opts,
},
["<leader>op"] = {
function()
local query = vim.fn.input "Enter query: "
if query and #query > 0 then
vim.cmd("ObsidianOpen " .. query)
end
end,
"Open Notes",
},
["<leader>on"] = {
function()
local title = vim.fn.input "Enter title: "
if title and #title > 0 then
vim.cmd("ObsidianNew " .. title)
end
end,
"New Notes",
},
["<leader>ot"] = {
function()
local offset = vim.fn.input "Enter offset: "
if offset and #offset > 0 then
vim.cmd("ObsidianToday " .. offset)
else
vim.cmd "ObsidianToday"
end
end,
"Today Note",
},
["<leader>of"] = {
function()
local note = vim.fn.input "Enter note: "
if note and #note > 0 then
vim.cmd("ObsidianSearch " .. note)
end
end,
"Search Note",
},
["<leader>ow"] = {
function()
local name = vim.fn.input "Enter name: "
if name and #name > 0 then
vim.cmd("ObsidianWorkspace " .. name)
end
end,
"Workspace Name",
},
["<leader>oi"] = {
function()
local image = vim.fn.input "Enter image: "
if image and #image > 0 then
vim.cmd("ObsidianPasteImg " .. image)
end
end,
"Paste Image",
},
["<leader>or"] = {
function()
local name = vim.fn.input "Enter name: "
if name and #name > 0 then
vim.cmd("ObsidianRename " .. name)
end
end,
"Rename",
},
["<leader>o["] = { "<cmd> ObsidianBacklinks <CR>", "Back Link" },
["<leader>o]"] = { "<cmd> ObsidianFollowLink <CR>", "Follow Link" },
["<leader>os"] = { "<cmd> ObsidianQuickSwitch <CR>", "Quick Switch" },
["<leader>ol"] = { "<cmd> ObsidianTomorrow <CR>", "Tomorrow Note" },
["<leader>oh"] = { "<cmd> ObsidianYesterday <CR>", "Yesterday Note" },
},
v = {
["<leader>ol"] = {
function()
local query = vim.fn.input "Enter query: "
if query and #query > 0 then
vim.cmd("ObsidianLink " .. query)
else
vim.cmd "ObsidianLink"
end
end,
"Link Query",
},
["<leader>on"] = {
function()
local note = vim.fn.input "Enter note: "
if note and #note > 0 then
vim.cmd("ObsidianLinkNew " .. note)
else
vim.cmd "ObsidianLinkNew"
end
end,
"New Link Note",
},
},
}
M.tabufline = {
n = {
["L"] = {
function()
require("nvchad.tabufline").tabuflineNext()
end,
"Goto next buffer",
},
["H"] = {
function()
require("nvchad.tabufline").tabuflinePrev()
end,
"Goto prev buffer",
},
},
}
return M
|