------------------------------------------------------------------------------ -- Misc -- ------------------------------------------------------------------------------ vim.keymap.set("i", "jk", "") vim.keymap.set("i", "kj", "") vim.keymap.set("", "q", "confirm quit") vim.keymap.set("", "x", "exit") vim.keymap.set("", "ww", "write") vim.keymap.set("", "x", "writesource %") vim.keymap.set("", "n", "nzz") vim.keymap.set("", "N", "Nzz") vim.keymap.set("", "", "nohls") vim.keymap.set("", "", "zz") vim.keymap.set("", "", "zz") local function swap(a, b) vim.keymap.set("", a, b) vim.keymap.set("", b, a) end swap(";", ":") swap("'", "`") vim.keymap.set("", "w", "") local function window_map(key, mapping) local k = '' local m = 'wincmd ' .. (mapping or key) .. '' vim.keymap.set({"", "i", "t"}, k, m) end window_map("h") window_map("j") window_map("k") window_map("l") ------------------------------------------------------------------------------ -- Plugin Maps -- ------------------------------------------------------------------------------ local M = {} function M.telescope() local telescope = require("telescope") local builtin = require("telescope.builtin") vim.keymap.set("", "ff", builtin.find_files) vim.keymap.set("", "fh", builtin.help_tags) vim.keymap.set("", "ft", builtin.builtin) vim.keymap.set("", "fm", builtin.man_pages) vim.keymap.set("", "fb", telescope.extensions.file_browser.file_browser) vim.keymap.set("", "fd", function() builtin.find_files({ cwd = "$DOTS", prompt_title = "< Dotfiles >" }) end) end function M.harpoon() vim.keymap.set("", "ha", require("harpoon.mark").add_file) vim.keymap.set("", "ho", require("harpoon.ui").toggle_quick_menu) vim.keymap.set("", "hf", function() require("harpoon.ui").nav_file(1) end) vim.keymap.set("", "hd", function() require("harpoon.ui").nav_file(2) end) vim.keymap.set("", "hs", function() require("harpoon.ui").nav_file(2) end) end function M.lsp(env) local opts = { buffer = env.buffer } vim.keymap.set("", "dn", vim.diagnostic.goto_next, opts) vim.keymap.set("", "dp", vim.diagnostic.goto_prev, opts) vim.keymap.set("", "de", vim.diagnostic.open_float, opts) vim.keymap.set("", "df", vim.lsp.buf.code_action, opts) vim.keymap.set("", "rn", vim.lsp.buf.rename, opts) vim.keymap.set("", "gD", vim.lsp.buf.declaration, opts) vim.keymap.set("", "gd", vim.lsp.buf.definition, opts) end function M.fugitive() vim.keymap.set("", "gs", "Git") end return M