summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/binds.lua
blob: 3f9c6a611881d5f7491defb6c0c2c8b65e637bbb (plain)
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
vim.g.mapleader = ' '
vim.b.mapleader = ' '

local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }

map('', 'Y', 'y$', opts)
map('n', '<C-L>', ':nohl<CR><C-L>', opts)
map('n', 'n', 'nzzzv', opts)
map('n', 'N', 'Nzzzv', opts)

map('n', '<leader>h', ':wincmd h<CR>', opts)
map('n', '<leader>j', ':wincmd j<CR>', opts)
map('n', '<leader>k', ':wincmd k<CR>', opts)
map('n', '<leader>l', ':wincmd l<CR>', opts)

map('n', '<C-n>', ':NvimTreeToggle<CR>', opts)
map('n', '<leader>n', ':NvimTreeFindFile<CR>', opts)

map('i', 'kj', '<Esc>', opts)
map('i', ',', ',<c-g>u', opts)
map('i', '.', '.<c-g>u', opts)
map('i', '[', '[<c-g>u', opts)
map('i', '!', '!<c-g>u', opts)
map('i', '?', '?<c-g>u', opts)

map('n', '<C-p>', '<cmd>Telescope find_files<cr>', opts)
map('n', '<leader>fg', '<cmd>Telescope live_grep<cr>', opts)
map('n', '<leader>fb', '<cmd>Telescope buffers<cr>', opts)
map('n', '<leader>fh', '<cmd>Telescope help_tags<cr>', opts)

map('n', '<leader>fu', '<cmd>Telescope lsp_references<cr>', opts)
map('n', '<leader>gd', '<cmd>Telescope lsp_definitions<cr>', opts)
map('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
map('n', '<leader>xd', '<cmd>Telescope lsp_document_diagnostics<cr>', opts)
map('n', '<leader>xD', '<cmd>Telescope lsp_workspace_diagnostics<cr>', opts)
map('n', '<leader>xn', '<cmd>lua vim.lsp.diagnostic.goto_next()<cr>', opts)
map('n', '<leader>xN', '<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>', opts)
map('n', '<leader>xx', '<cmd>Telescope lsp_code_actions<cr>', opts)
map('n', '<leader>xX', '<cmd>Telescope lsp_range_code_actions<cr>', opts)

map('v', 'J', ":m '>+1<CR>gv=gv", { noremap = true })
map('v', 'K', ":m '<-2<CR>gv=gv", { noremap = true })