summaryrefslogtreecommitdiff
path: root/lua/core/keymaps.lua
blob: 1305224d05d100fe445345168b41a1c4dfea39eb (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
45
46
-----------------------------------------------------------
-- 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>') -- FZF show open buffers
map('n', '<leader>F', ':Files<CR>')   -- FZF show files
map('n', '<leader>A', ':Rg<CR>')      -- FZF call ripgrep
map('n', '<leader>C', ':Commits<CR>') -- FZF show git commits
map('n', '<leader>M', ':Maps<CR>')    -- FZF show normal mode mappings

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