Skip to content

Commit c2a6a63

Browse files
authored
Update remap.lua
1 parent dc80f0a commit c2a6a63

File tree

1 file changed

+49
-29
lines changed

1 file changed

+49
-29
lines changed

lua/theprimeagen/remap.lua

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
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
32

4-
-- Project view
3+
-- [[ NetRW cmds Project view & vertical window split ]]
54
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
6-
-- split window vertically : Vex
75
vim.keymap.set("n", "<leader>ve", vim.cmd.Vex)
86

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
139
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
1410
-- J takes the line below and appends it to your current line with a space
1511
-- And this one keeps your cursor in one place dispite movving other lines
1612
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
17-
1813
vim.keymap.set("n", "J", "mzJ`z")
1914
-- The two below keeps the cursor in the middle when scrolling with ctrl + d & u
2015
-- Makes searching the file less disorienting.
@@ -25,29 +20,24 @@ vim.keymap.set("n", "<C-u>", "<C-u>zz")
2520
vim.keymap.set("n", "n", "nzzzv")
2621
vim.keymap.set("n", "N", "Nzzzv")
2722

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]])
3426

27+
-- normal mode, then visual line mode, then spacebar shift
3528
-- greatest remap ever
3629
-- Pasting highlighted text over a pre-selected highligted text
3730
-- Deletes highlighted word into the 'void' register and then paste it over.
3831
vim.keymap.set("x", "<leader>p", [["_dP]])
3932

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
4236
vim.keymap.set({"n", "v"}, "<leader>y", [["+y]])
4337
vim.keymap.set("n", "<leader>Y", [["+Y]])
4438

4539
vim.keymap.set({"n", "v"}, "<leader>d", [["_d]])
4640

47-
-- This is going to get me cancelled
48-
vim.keymap.set("i", "<C-c>", "<Esc>")
49-
50-
vim.keymap.set("n", "Q", "<nop>")
5141
-- When using Tmux: ctrl + f and now fuzzy find in another terminal session
5242
vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>")
5343
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format)
@@ -58,16 +48,46 @@ vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
5848
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
5949
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
6050

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.
6252
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
6353

6454
-- Make the file executable without having to exit and chmoding it manually.
6555
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
6656

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

Comments
 (0)