1
- -- For explinations see https://youtu.be/w7i4amO_zaE and skip to 24:24 The Best remaps
2
- vim .g .mapleader = " "
1
+ -- This keymaps file needs to be "required" in /nvim/config/init.lua
3
2
4
- -- Project view
3
+ -- [[ NetRW cmds Project view & vertical window split ]]
5
4
vim .keymap .set (" n" , " <leader>pv" , vim .cmd .Ex )
6
- -- split window vertically : Vex
7
5
vim .keymap .set (" n" , " <leader>ve" , vim .cmd .Vex )
8
6
9
- -- when highlighting a line, press shift + j or k
10
- -- and yoiu can move an entite line or lines up or down.
11
- -- Example: taking some lines of code and moving them into an if statement
12
- -- The lines auto indent when you are done moving them.
7
+ -- [ ! Move an entite line or lines up or down. ]]
8
+ -- when highlighting a line, press shift + j or k
13
9
vim .keymap .set (" v" , " J" , " :m '>+1<CR>gv=gv" )
14
10
-- J takes the line below and appends it to your current line with a space
15
11
-- And this one keeps your cursor in one place dispite movving other lines
16
12
vim .keymap .set (" v" , " K" , " :m '<-2<CR>gv=gv" )
17
-
18
13
vim .keymap .set (" n" , " J" , " mzJ`z" )
19
14
-- The two below keeps the cursor in the middle when scrolling with ctrl + d & u
20
15
-- Makes searching the file less disorienting.
@@ -25,29 +20,24 @@ vim.keymap.set("n", "<C-u>", "<C-u>zz")
25
20
vim .keymap .set (" n" , " n" , " nzzzv" )
26
21
vim .keymap .set (" n" , " N" , " Nzzzv" )
27
22
28
- vim .keymap .set (" n" , " <leader>vwm" , function ()
29
- require (" vim-with-me" ).StartVimWithMe ()
30
- end )
31
- vim .keymap .set (" n" , " <leader>svwm" , function ()
32
- require (" vim-with-me" ).StopVimWithMe ()
33
- end )
23
+ -- Pasting highlighted text over a pre-selected highligted text
24
+ -- Deletes highlighted word into the 'void' register and then paste it over.
25
+ vim .keymap .set (" x" , " <leader>p" , [[ "_dP]] )
34
26
27
+ -- normal mode, then visual line mode, then spacebar shift
35
28
-- greatest remap ever
36
29
-- Pasting highlighted text over a pre-selected highligted text
37
30
-- Deletes highlighted word into the 'void' register and then paste it over.
38
31
vim .keymap .set (" x" , " <leader>p" , [[ "_dP]] )
39
32
40
- -- next greatest remap ever : asbjornHaland
41
- -- leader y yanks text to the system clipboard enabling you to pate elsewhere
33
+ -- YANK TEXT TO THE SYSTEM CLIPBOARD
34
+ -- Normal mode, then leader yy
35
+ -- yanks text to the system clipboard enabling you to pate elsewhere
42
36
vim .keymap .set ({" n" , " v" }, " <leader>y" , [[ "+y]] )
43
37
vim .keymap .set (" n" , " <leader>Y" , [[ "+Y]] )
44
38
45
39
vim .keymap .set ({" n" , " v" }, " <leader>d" , [[ "_d]] )
46
40
47
- -- This is going to get me cancelled
48
- vim .keymap .set (" i" , " <C-c>" , " <Esc>" )
49
-
50
- vim .keymap .set (" n" , " Q" , " <nop>" )
51
41
-- When using Tmux: ctrl + f and now fuzzy find in another terminal session
52
42
vim .keymap .set (" n" , " <C-f>" , " <cmd>silent !tmux neww tmux-sessionizer<CR>" )
53
43
vim .keymap .set (" n" , " <leader>f" , vim .lsp .buf .format )
@@ -58,16 +48,46 @@ vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
58
48
vim .keymap .set (" n" , " <leader>k" , " <cmd>lnext<CR>zz" )
59
49
vim .keymap .set (" n" , " <leader>j" , " <cmd>lprev<CR>zz" )
60
50
61
- -- space + s opens a menu and begin replacing the word on which your cursor lies.
51
+ -- ! Extremely useful: space + s opens a menu and begin replacing the word on which your cursor lies.
62
52
vim .keymap .set (" n" , " <leader>s" , [[ :%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]] )
63
53
64
54
-- Make the file executable without having to exit and chmoding it manually.
65
55
vim .keymap .set (" n" , " <leader>x" , " <cmd>!chmod +x %<CR>" , { silent = true })
66
56
67
- vim .keymap .set (" n" , " <leader>vpp" , " <cmd>e ~/.dotfiles/nvim/.config/nvim/lua/theprimeagen/packer.lua<CR>" );
68
- vim .keymap .set (" n" , " <leader>mr" , " <cmd>CellularAutomaton make_it_rain<CR>" );
69
-
70
- vim .keymap .set (" n" , " <leader><leader>" , function ()
71
- vim .cmd (" so" )
72
- end )
73
-
57
+ -- Diagnostic keymaps
58
+ vim .keymap .set (' n' , ' [d' , vim .diagnostic .goto_prev , { desc = ' Go to previous diagnostic message' })
59
+ vim .keymap .set (' n' , ' ]d' , vim .diagnostic .goto_next , { desc = ' Go to next diagnostic message' })
60
+ vim .keymap .set (' n' , ' <leader>e' , vim .diagnostic .open_float , { desc = ' Open floating diagnostic message' })
61
+ vim .keymap .set (' n' , ' <leader>q' , vim .diagnostic .setloclist , { desc = ' Open diagnostics list' })
62
+
63
+ -- ThePrimeagen's Flashy Highlight on yank
64
+ local augroup = vim .api .nvim_create_augroup
65
+ local ThePrimeagenGroup = augroup (' ThePrimeagen' , {})
66
+
67
+ local autocmd = vim .api .nvim_create_autocmd
68
+ local yank_group = augroup (' HighlightYank' , {})
69
+
70
+ function R (name )
71
+ require (" plenary.reload" ).reload_module (name )
72
+ end
73
+
74
+ autocmd (' TextYankPost' , {
75
+ group = yank_group ,
76
+ pattern = ' *' ,
77
+ callback = function ()
78
+ vim .highlight .on_yank ({
79
+ higroup = ' IncSearch' ,
80
+ timeout = 40 ,
81
+ })
82
+ end ,
83
+ })
84
+
85
+ autocmd ({" BufWritePre" }, {
86
+ group = ThePrimeagenGroup ,
87
+ pattern = " *" ,
88
+ command = [[ %s/\s\+$//e]] ,
89
+ })
90
+
91
+ -- attempt opaque background: It worked!
92
+ vim .api .nvim_set_hl (0 , " Normal" , { bg = " none" })
93
+ vim .api .nvim_set_hl (0 , " NormalFloat" , { bg = " none" })
0 commit comments