-
Notifications
You must be signed in to change notification settings - Fork 0
/
keymaps.lua
54 lines (42 loc) · 1.41 KB
/
keymaps.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
local map = vim.keymap.set
-- Disable movement with cursor keys:
for _, k in ipairs({ 'up', 'down', 'left', 'right' }) do
map('n', '<' .. k .. '>', '<nop>')
map('i', '<' .. k .. '>', '<nop>')
end
-- Disable man page lookup of word under cursor with K key:
map('n', 'K', '<nop>')
-- Disable tab cycling keys (use buffers):
map('n', 'gT', '<nop>')
map('n', 'gt', '<nop>')
-- Move up/down by display lines when long lines wrap:
map('n', 'j', 'gj')
map('n', 'k', 'gk')
-- Keep search matches in the middle of the window:
for _, k in ipairs({ '*', '#', 'n', 'N' }) do
map('n', k, k .. 'zzzv')
end
-- Stay in visual mode when indenting:
map('v', '<', '<gv')
map('v', '>', '>gv')
-- Clear search highlight when clearing screen:
map('n', '<c-l>', ':nohlsearch<cr><c-l>', { silent = true })
vim.g.mapleader = ','
map('n', '<leader>cp', '"+p', { desc = 'paste from system clipboard' })
map('v', '<leader>cy', '"+y', { desc = 'yank to system clipboard' })
map('n', '<leader>p', ':bp<CR>', { desc = 'previous buffer' })
map('n', '<leader>n', ':bn<CR>', { desc = 'next buffer' })
map('n', '<leader>d', ':bd<CR>', { desc = 'delete buffer' })
map(
'n',
'<leader>e',
':e <C-R>=expand("%:p:h") . "/"<CR>',
{ desc = 'edit in cwd' }
)
map(
'n',
'<leader>gc',
':!cd %:p:h && git add . && git ci -am sync && git push<CR>',
{ desc = 'git commit and sync' }
)
map('n', 'gl', vim.diagnostic.open_float, { desc = 'view diagnostic' })