local utils = require("utils") local g = vim.g g.mapleader = " " g.maplocalleader = " " local move_up = { "v:count || mode(1)[0:1] == \"no\" ? \"k\" : \"gk\"", { expr = true } } local move_down = { "v:count || mode(1)[0:1] == \"no\" ? \"j\" : \"gj\"", { expr = true } } for _, mode_mapping in ipairs({ { "n", { { "K", "", }, { "grn", "", }, { "gra", "", }, { "grr", "", }, { "gri", "", }, { "gO", "", }, { "grt", "", }, -- Navigation { "", "h", }, { "", "j", }, { "", "k", }, { "", "l", }, { "", "h", }, { "", "j", }, { "", "k", }, { "", "l", }, -- Window { "", "q", }, -- Disable current highlights { "", " noh ", }, -- Copies the entire file { "", ":%y+", { silent = true } }, -- Allow moving the cursor through wrapped lines with and -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ -- empty mode is same as using :map -- also don't use g[j|k] when in operator pending mode, -- so it doesn't alter d, y or c behaviour { "", move_up[1], move_up[2], }, { "", move_down[1], move_down[2], }, { "j", move_down[1], move_down[2], }, { "k", move_up[1], move_up[2], }, -- Maps to remove { "", "", }, { "[d", function() vim.diagnostic.jump({ count = -1, float = false }) end }, { "]d", function() vim.diagnostic.jump({ count = 1, float = false }) end }, { "gcp", function() for _, cmd in ipairs({ "\"zyy", "gcc", "\"zp", }) do vim.cmd.normal({ cmd }) end end }, { "", ":$tabnew %", { silent = true }, }, { "", ":1tabn", { silent = true }, }, { "", ":2tabn", { silent = true }, }, { "", ":3tabn", { silent = true }, }, { "", ":4tabn", { silent = true }, }, { "", ":5tabn", { silent = true }, }, { "", ":6tabn", { silent = true }, }, { "", ":7tabn", { silent = true }, }, { "", ":8tabn", { silent = true }, }, { "z/", '/\\%>=line("w0")-1l\\%<=line("w$")+1l', { silent = false, desc = "Search in viewport" }, }, { "z?", '?\\%>=line("w0")-1l\\%<=line("w$")+1l', { silent = false, desc = "Search in viewport" }, }, { "u", ":Undotree", { silent = true } }, } }, { "v", { { "", move_up[1], move_up[2], }, { "", move_down[1], move_down[2], }, { "j", move_down[1], move_down[2], }, { "k", move_up[1], move_up[2], }, { "", ">gv", }, { "", "``>?\\%V", }, }, }, { "x", { { "", move_up[1], move_up[2], }, { "", move_down[1], move_down[2], }, { "j", move_down[1], move_down[2], }, { "k", move_up[1], move_up[2], }, { "p", "p:let @+=@0:let @\"=@0", { silent = true }, }, } }, { "t", { { "", "", }, } }, }) do utils.set_keymap_list(mode_mapping[2], mode_mapping[1]) end