summaryrefslogtreecommitdiffstats
path: root/lua/user/keymaps.lua
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2022-03-07 14:43:57 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2022-03-07 14:43:57 +0100
commit596823bc99e656d3913ad7fe7f6c0f27a30c0110 (patch)
tree9ddf40caf018cc630d445db327d7b8d52994f921 /lua/user/keymaps.lua
parentcbcab8684e06379c9f5c51cfc9cac68d8684fe0c (diff)
downloadvim-596823bc99e656d3913ad7fe7f6c0f27a30c0110.zip
vim-596823bc99e656d3913ad7fe7f6c0f27a30c0110.tar.gz
switch to neovim + lua
Diffstat (limited to 'lua/user/keymaps.lua')
-rw-r--r--lua/user/keymaps.lua82
1 files changed, 82 insertions, 0 deletions
diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua
new file mode 100644
index 0000000..caf78a4
--- /dev/null
+++ b/lua/user/keymaps.lua
@@ -0,0 +1,82 @@
+local opts = { noremap = true, silent = true }
+
+local term_opts = { silent = true }
+
+-- Shorten function name
+local keymap = vim.api.nvim_set_keymap
+
+--Remap space as leader key
+keymap("", "<Space>", "<Nop>", opts)
+vim.g.mapleader = " "
+vim.g.maplocalleader = " "
+
+-- Modes
+-- normal_mode = "n",
+-- insert_mode = "i",
+-- visual_mode = "v",
+-- visual_block_mode = "x",
+-- term_mode = "t",
+-- command_mode = "c",
+
+-- Normal --
+-- Better window navigation
+keymap('n', ',t', '<C-w>j', opts)
+keymap('n', ',s', '<C-w>k', opts)
+keymap('n', ',c', '<C-w>h', opts)
+keymap('n', ',r', '<C-w>l', opts)
+keymap('n', ',<SPACE>', ':split<CR>', opts)
+keymap('n', ',<CR>', ':vsplit<CR>', opts)
+
+-- jump back from tag
+keymap('n', ',,', ':pop<CR>', opts)
+
+-- lexpore navigation keys are not bepo : https://vonheikemen.github.io/devlog/tools/using-netrw-vim-builtin-file-explorer/
+-- keymap('n', '<Leader>e', ':Lex 20<CR>', opts)
+-- switch to https://github.com/kyazdani42/nvim-tree.lua
+keymap('n', '<Leader>e', ':NvimTreeToggle<CR>', opts)
+
+-- Resize with arrows
+keymap("n", "<C-Up>", ":resize +2<CR>", opts)
+keymap("n", "<C-Down>", ":resize -2<CR>", opts)
+keymap("n", "<C-Left>", ":vertical resize +2<CR>", opts)
+keymap("n", "<C-Right>", ":vertical resize -2<CR>", opts)
+
+-- Navigate buffers
+keymap("n", "<S-Q>", ":bnext<CR>", opts)
+keymap("n", "<S-H>", ":bprevious<CR>", opts)
+
+-- Move text up and down
+-- keymap("n", "<A-j>", "<Esc>:m .+1<CR>==gi", opts)
+-- keymap("n", "<A-k>", "<Esc>:m .-2<CR>==gi", opts)
+
+-- Insert --
+-- Press jk fast to enter
+-- keymap("i", "jk", "<ESC>", opts)
+
+-- Visual --
+-- Stay in indent mode
+keymap("v", "<", "<gv", opts)
+keymap("v", ">", ">gv", opts)
+
+-- Move text up and down
+-- keymap("v", "<A-j>", ":m .+1<CR>==", opts)
+-- keymap("v", "<A-k>", ":m .-2<CR>==", opts)
+keymap("v", "p", '"_dP', opts) -- no not overwrite the register content when past to replace
+
+-- Visual Block --
+-- Move text up and down
+-- keymap("x", "J", ":move '>+1<CR>gv-gv", opts)
+-- keymap("x", "K", ":move '<-2<CR>gv-gv", opts)
+-- keymap("x", "<A-j>", ":move '>+1<CR>gv-gv", opts)
+-- keymap("x", "<A-k>", ":move '<-2<CR>gv-gv", opts)
+
+-- Terminal --
+-- Better terminal navigation
+-- keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", term_opts)
+-- keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts)
+-- keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts)
+-- keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts)
+
+-- Telescope
+keymap("n", "<Leader>b", "<cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})<cr>", opts)
+keymap("n", "<Leader>f", "<cmd>lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{previewer = false})<cr>", opts)