2022-02-08 21:39:40 +01:00
|
|
|
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",
|
|
|
|
|
2022-02-21 09:37:08 +01:00
|
|
|
-- Disable Arrow keys to force myself to the Vim-Way of movement --
|
|
|
|
keymap("i", "<Up>", "<Nop>", opts)
|
|
|
|
keymap("i", "<Down>", "<Nop>", opts)
|
|
|
|
keymap("i", "<Left>", "<Nop>", opts)
|
|
|
|
keymap("i", "<Right>", "<Nop>", opts)
|
|
|
|
|
|
|
|
keymap("n", "<Up>", "<Nop>", opts)
|
|
|
|
keymap("n", "<Down>", "<Nop>", opts)
|
|
|
|
keymap("n", "<Left>", "<Nop>", opts)
|
|
|
|
keymap("n", "<Right>", "<Nop>", opts)
|
|
|
|
|
2022-02-13 23:12:17 +01:00
|
|
|
-- Remap some language specific stuff --
|
|
|
|
keymap("n", "ü", "{", opts)
|
|
|
|
keymap("n", "<C-ü>", "<C-{>", opts)
|
|
|
|
|
|
|
|
keymap("n", "+", "}", opts)
|
|
|
|
keymap("n", "<C-+>", "<C-}>", opts)
|
|
|
|
|
2022-02-08 21:39:40 +01:00
|
|
|
-- Normal --
|
|
|
|
-- Better window navigation
|
2022-03-28 14:22:26 +02:00
|
|
|
keymap("n", "<C-h>", "<C-w>h", opts)
|
|
|
|
keymap("n", "<C-j>", "<C-w>j", opts)
|
|
|
|
keymap("n", "<C-k>", "<C-w>k", opts)
|
|
|
|
keymap("n", "<C-l>", "<C-w>l", opts)
|
2022-02-08 21:39:40 +01:00
|
|
|
|
2022-02-13 23:12:17 +01:00
|
|
|
keymap("n", "<leader>e", ":NvimTreeToggle<cr>", opts)
|
2022-02-08 21:39:40 +01:00
|
|
|
|
|
|
|
-- 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-l>", ":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)
|
|
|
|
|
|
|
|
-- 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
|
2022-03-28 14:22:26 +02:00
|
|
|
keymap("t", "<Esc>", "<C-\\><C-n>", term_opts)
|
2022-02-08 21:39:40 +01:00
|
|
|
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)
|
|
|
|
|
|
|
|
-- keymap("n", "<leader>f", "<cmd>Telescope find_files<cr>", opts)
|
|
|
|
keymap("n", "<leader>f", "<cmd>lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ previewer = false }))<cr>", opts)
|
|
|
|
keymap("n", "<c-t>", "<cmd>Telescope live_grep<cr>", opts)
|
|
|
|
|
2022-02-24 19:42:49 +01:00
|
|
|
-- Format document --
|
|
|
|
keymap("n", "<leader><leader>f", "<cmd>Format<cr>", opts)
|
|
|
|
|
|
|
|
-- close buffer --
|
2022-06-09 16:25:51 +02:00
|
|
|
keymap("n", "<leader>q", "<cmd>Bdelete! %d<cr>", opts)
|
2022-03-28 16:02:33 +02:00
|
|
|
|
|
|
|
-- toggle whitespace --
|
|
|
|
keymap("n", "<leader>w", "<cmd>set list!<cr>", opts)
|
|
|
|
|
|
|
|
-- toggle gitsign line blame --
|
|
|
|
keymap("n", "<leader>g", "<cmd>Gitsigns toggle_current_line_blame<cr>", opts)
|