summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/mappings.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/mappings.lua')
-rw-r--r--.config/nvim/lua/mappings.lua66
1 files changed, 66 insertions, 0 deletions
diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua
new file mode 100644
index 0000000..1233bf3
--- /dev/null
+++ b/.config/nvim/lua/mappings.lua
@@ -0,0 +1,66 @@
+vim.api.nvim_set_keymap('n', '<Space>', '<NOP>', { noremap = true, silent = true })
+vim.g.mapleader = ' '
+
+-- no hl
+vim.api.nvim_set_keymap('n', '<Leader>h', ':set hlsearch!<CR>', { noremap = true, silent = true })
+
+-- explorer
+vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeToggle<CR>', { noremap = true, silent = true })
+
+
+-- better window movement
+vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', { silent = true })
+vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', { silent = true })
+vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', { silent = true })
+vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', { silent = true })
+
+-- TODO fix this
+-- Terminal window navigation
+vim.cmd([[
+ tnoremap <C-h> <C-\><C-N><C-w>h
+ tnoremap <C-j> <C-\><C-N><C-w>j
+ tnoremap <C-k> <C-\><C-N><C-w>k
+ tnoremap <C-l> <C-\><C-N><C-w>l
+ inoremap <C-h> <C-\><C-N><C-w>h
+ inoremap <C-j> <C-\><C-N><C-w>j
+ inoremap <C-k> <C-\><C-N><C-w>k
+ inoremap <C-l> <C-\><C-N><C-w>l
+ tnoremap <Esc> <C-\><C-n>
+]])
+
+-- TODO fix this
+-- resize with arrows
+vim.cmd([[
+ nnoremap <silent> <C-Up> :resize -2<CR>
+ nnoremap <silent> <C-Down> :resize +2<CR>
+ nnoremap <silent> <C-Left> :vertical resize -2<CR>
+ nnoremap <silent> <C-Right> :vertical resize +2<CR>
+]])
+
+
+-- better indenting
+vim.api.nvim_set_keymap('v', '<', '<gv', { noremap = true, silent = true })
+vim.api.nvim_set_keymap('v', '>', '>gv', { noremap = true, silent = true })
+
+-- I hate escape
+vim.api.nvim_set_keymap('i', 'jk', '<ESC>', { noremap = true, silent = true })
+vim.api.nvim_set_keymap('i', 'kj', '<ESC>', { noremap = true, silent = true })
+vim.api.nvim_set_keymap('i', 'jj', '<ESC>', { noremap = true, silent = true })
+
+-- Tab switch buffer
+vim.api.nvim_set_keymap('n', '<TAB>', ':bnext<CR>', { noremap = true, silent = true })
+vim.api.nvim_set_keymap('n', '<S-TAB>', ':bprevious<CR>', { noremap = true, silent = true })
+
+-- Move selected line / block of text in visual mode
+vim.api.nvim_set_keymap('x', 'K', ':move \'<-2<CR>gv-gv', { noremap = true, silent = true })
+vim.api.nvim_set_keymap('x', 'J', ':move \'>+1<CR>gv-gv', { noremap = true, silent = true })
+
+
+-- Better nav for omnicomplete
+vim.cmd('inoremap <expr> <c-j> (\"\\<C-n>\")')
+vim.cmd('inoremap <expr> <c-k> (\"\\<C-p>\")')
+-- vim.cmd('inoremap <expr> <TAB> (\"\\<C-n>\")')
+-- vim.cmd('inoremap <expr> <S-TAB> (\"\\<C-p>\")')
+
+-- TAB Complete
+--vim.api.nvim_set_keymap('i', '<expr><TAB>', 'pumvisible() ? \"\\<C-n>\" : \"\\<TAB>\"', { noremap = true, silent = true })