local m = require("utility.mappings") local vim = require("vim") local g = vim.g -- This is a bit silly, but I don't like passing the mode argument g.mapleader = "\\" -- Unmap arrow keys in normal mode to remove bad habits m.keymap("n", "", "") m.keymap("n", "", "") m.keymap("n", "", "") m.keymap("n", "", "") -- Tab navigation m.keymap("n", "", "gt") m.keymap("n", "", "gT") m.keymap("n", "", ":tabnew") m.keymap("n", "", ":tabmove +") m.keymap("n", "", ":tabmove -") m.keymap("n", "", ":tabp") m.keymap("n", "", ":tabn") m.keymap("n", "", ":tabc") -- Buffer navigation m.keymap("n", "", ":bn") m.keymap("n", "", ":bp") m.keymap("n", "", ":bd") -- Set splits navigation to just ALT + hjkl m.keymap("n", "", "h") m.keymap("n", "", "j") m.keymap("n", "", "k") m.keymap("n", "", "l") -- Split size adjusting m.keymap("n", "", ":vertical resize +3") m.keymap("n", "", ":vertical resize -3") m.keymap("n", "", ":resize +3") m.keymap("n", "", ":resize -3") -- Define some common shortcuts m.keymap("n", "", ":w") m.keymap("i", "", ":wi") m.keymap("n", "", ":undo") m.keymap("n", "", ":redo") -- Terminal m.keymap("n", "", ":split term://zsh:resize -7i") m.keymap("n", "", ":vnew term://zshi") m.keymap("n", "", ":tabnew term://zshi") m.keymap("t", "", "") -- Use space for folding/unfolding sections m.keymap("n", "", "za") m.keymap("v", "", "zf") -- Use shift to quickly move 10 lines up/down m.keymap("n", "K", "10k") m.keymap("n", "J", "10j") -- Moving lines around m.keymap("v", "", ":m '>+1gv=gv") m.keymap("v", "", ":m '<-2gv=gv") m.keymap("i", "", ":m .+1==i") m.keymap("i", "", ":m .-2==i") m.keymap("n", "j", ":m .+1==") m.keymap("n", "k", ":m .-2==") -- Quick word replacing (use . for next word) m.keymap("n", "cn", "*``cgn") m.keymap("n", "cN", "*``cgN") -- Enable/Disable auto commenting m.keymap("n", "c", ":setlocal formatoptions-=cro") m.keymap("n", "C", ":setlocal formatoptions+=cro") -- Don't leave visual mode after indenting m.keymap("v", "<", "", ">gv") -- Center (and unfold) after going to next/prev search item m.keymap("n", "n", "nzzzv") m.keymap("n", "N", "Nzzzv") -- System clipboard copying m.keymap("v", "", '"+y') -- Alias replace all m.keymap("n", "", ":%s//gI", {silent=false}) -- Stop search highlight with Esc m.keymap("n", "", ":noh") -- Start spell-check m.keymap("n", "s", ":setlocal spell! spelllang=en_us") -- Run shell check m.keymap("n", "p", ":!shellckeck %") -- Compile opened file (using custom script) m.keymap("n", "", ":w | !comp %") -- Close all opened buffers m.keymap("n", "Q", ":bufdo bdelete") -- Don't set the incredibely annoying mappings that trigger dynamic SQL -- completion with dbext and keeps on freezing vim whenever pressed with -- a message saying that dbext plugin isn't installed -- See :h ft-sql.txt vim.g.omni_sql_no_default_maps = 1