summaryrefslogtreecommitdiff
path: root/lua/core/keymaps.lua
blob: 07366538dc62d8195ab8fd1b19b9495f2acda56f (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
44
-----------------------------------------------------------
-- Define keymaps of Neovim and installed plugins.
-----------------------------------------------------------

local function map(mode, lhs, rhs, opts)
	local options = { noremap = true, silent = true }
	if opts then
		options = vim.tbl_extend('force', options, opts)
	end
	vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end

-- Change leader to a comma
vim.g.mapleader = ','

-----------------------------------------------------------
-- Neovim shortcuts
-----------------------------------------------------------

-- Disable arrow keys
map('', '<up>', '<nop>')
map('', '<down>', '<nop>')
map('', '<left>', '<nop>')
map('', '<right>', '<nop>')

-- Reload configuration without restart nvim
map('n', '<leader>r', ':so %<CR>')

-- Change split orientation
map('n', '<leader>tk', '<C-w>t<C-w>K') -- change vertical to horizontal
map('n', '<leader>th', '<C-w>t<C-w>H') -- change horizontal to vertical

map('n', 'M-j', ':resize -2<CR>')
map('n', 'M-k', ':resize +2<CR>')
map('n', 'M-l', ':vertical resize -2<CR>')
map('n', 'M-h', ':vertical resize +2<CR>')

map('t', 'C-w', '<C-\\><C-n><C-w>')

map('n', '<leader>b', ':Buffers<CR>');
map('n', '<leader>n', ':Files<CR>');

map('n', '<silent><leader>l', ':Buffers<CR>')
map('n', '<leader>e', ':NvimTreeToggle<CR>')