aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config/nvim/after/plugin/mappings.lua
blob: f16c720b7d2815e592734226a2eb48492b5e9384 (plain) (blame)
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
local map = require("mapper")

map.n("<Space>", "<Nop>")

-- make an accidental ; press also enter command mode
-- temporarily disabled to to vim-sneak plugin
map.n(";", ":")

-- highlight last inserted text
map.n("gV", "`[v`]")

map.n("<down>", "<c-e>")
map.n("<up>", "<c-y>")

-- go to first non-blank character of current line
map.n("<c-a>", "^")
map.v("<c-a>", "^")
map.n("<c-e>", "$")
map.v("<c-e>", "$")

-- This extends p in visual mode (note the noremap), so that if you paste from
-- the unnamed (ie. default) register, that register content is not replaced by
-- the visual selection you just pasted over–which is the default behavior.
-- This enables the user to yank some text and paste it over several places in
-- a row, without using a named register
-- map.v('p', "p:if v:register == '"'<Bar>let @@=@0<Bar>endif<cr>")
map.v("p", 'p:let @+=@0<CR>:let @"=@0<CR>')

map.v("<leader>p", '"_dP')
map.n("<leader>d", '"_d')
map.n("<leader>D", '"_D')
map.map("", "<leader>c", '"_c')
map.map("", "<leader>C", '"_C')

-- Find and Replace binds
map.ncmdi("<leader>s", "%s/")
map.vcmdi("<leader>s", "s/")
map.ncmdi("<leader>gs", '%s/<c-r>"/')
map.vcmdi("<leader>gs", 's/<c-r>"/')
map.ncmdi("<Leader>S", "%s/<C-r><C-w>/")

map.ncmd("<leader>x", "wall")
map.ncmd("<leader>z", "wqall")
map.ncmd("<leader>q", "quitall")
map.ncmd("<localleader>x", "update")

map.t("<Esc>", "<c-\\><c-n>", { silent = true, noremap = true, expr = true })

map.n("[e", function()
  vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR })
end)
map.n("]e", function()
  vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR })
end)