From 0721b537a8aa3be8b70c183b25951494df9dcd0e Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sun, 14 May 2023 09:10:26 +0100 Subject: Installs nvim config base-idea --- nvim/lua/keymaps.lua | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 nvim/lua/keymaps.lua (limited to 'nvim/lua/keymaps.lua') diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua new file mode 100644 index 0000000..726e591 --- /dev/null +++ b/nvim/lua/keymaps.lua @@ -0,0 +1,83 @@ +-- Shorten function name +local keymap = vim.keymap.set +-- Silent keymap option +local opts = { silent = true } + +--Remap space as leader key +keymap("", "", "", opts) +vim.g.mapleader = " " + +-- 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", "", "h", opts) +keymap("n", "", "j", opts) +keymap("n", "", "k", opts) +keymap("n", "", "l", opts) + +-- Resize with arrows +keymap("n", "", ":resize -2", opts) +keymap("n", "", ":resize +2", opts) +keymap("n", "", ":vertical resize -2", opts) +keymap("n", "", ":vertical resize +2", opts) + +-- Navigate buffers +keymap("n", "", ":bnext", opts) +keymap("n", "", ":bprevious", opts) + +-- Clear highlights +keymap("n", "h", "nohlsearch", opts) + +-- Close buffers +keymap("n", "", "Bdelete!", opts) + +-- Better paste +keymap("v", "p", '"_dP', opts) + +-- Insert -- +-- Press jk fast to enter +keymap("i", "jk", "", opts) + +-- Visual -- +-- Stay in indent mode +keymap("v", "<", "", ">gv", opts) + +-- Plugins -- + +-- NvimTree +keymap("n", "e", ":NvimTreeToggle", opts) + +-- Telescope +keymap("n", "ff", ":Telescope find_files", opts) +keymap("n", "ft", ":Telescope live_grep", opts) +keymap("n", "fp", ":Telescope projects", opts) +keymap("n", "fb", ":Telescope buffers", opts) + +-- Git +keymap("n", "gg", "lua _LAZYGIT_TOGGLE()", opts) + +-- Comment +keymap("n", "/", "lua require('Comment.api').toggle.linewise.current()", opts) +keymap("x", "/", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) + +-- DAP +keymap("n", "db", "lua require'dap'.toggle_breakpoint()", opts) +keymap("n", "dc", "lua require'dap'.continue()", opts) +keymap("n", "di", "lua require'dap'.step_into()", opts) +keymap("n", "do", "lua require'dap'.step_over()", opts) +keymap("n", "dO", "lua require'dap'.step_out()", opts) +keymap("n", "dr", "lua require'dap'.repl.toggle()", opts) +keymap("n", "dl", "lua require'dap'.run_last()", opts) +keymap("n", "du", "lua require'dapui'.toggle()", opts) +keymap("n", "dt", "lua require'dap'.terminate()", opts) + +-- Lsp +keymap("n", "lf", "lua vim.lsp.buf.format{ async = true }", opts) -- cgit v1.2.3