-- Keymap File local map = vim.keymap.set -- jk exit from insert mode map("i", "jk", "noh", { silent = true }) ---- -- Movements ---- -- More powerful J and K (use 6j/6k) -- Via Pseudometa (https://nanotipsforvim.prose.sh/motion-setup--hjkl-as-amplified-hjkl) map({ "n", "x" }, "", "6j") map({ "n", "x" }, "", "6k") -- And fix the keys to other ones map({ "n", "x" }, "M", "J", { desc = "Merge" }) -- Replace the join command map("n", "gh", vim.lsp.buf.hover, { desc = "Hover" }) -- Code action hover -- Move to window using the hjkl keys map("n", "", "h", { desc = "Go to left window", remap = true }) map("n", "", "j", { desc = "Go to lower window", remap = true }) map("n", "", "k", { desc = "Go to upper window", remap = true }) map("n", "", "l", { desc = "Go to right window", remap = true }) -- Move between buffers map("n", "", "BufferLineCyclePrev", { desc = "Move buffer left", silent = true }) map("n", "", "BufferLineCycleNext", { desc = "Move buffer right", silent = true }) map("n", "<", "BufferLineMovePrev", { desc = "Move buffer left", silent = true }) map("n", ">", "BufferLineMoveNext", { desc = "Move buffer right", silent = true }) -- ToggleTerm Bindings map("n", "a", "ToggleTerm name=main", { desc = "Floating Terminal", silent = true }) ---- -- Cool Macros ---- -- Quit All map("n", "qq", "qa", { desc = "Quit all" }) -- Copy and paste from system clipboard map({ "n", "x" }, "y", '"+y', { desc = "Yank to system clipboard", silent = true }) map({ "n", "x" }, "p", '"+p', { desc = "Paste after from system clipboard", silent = true }) map({ "n", "x" }, "P", '"+P', { desc = "Paste before from system clipboard", silent = true }) -- Neotree map("n", "e", function() require("neo-tree.command").execute({ action = "show", position = "right", toggle = true, dir = vim.loop.cwd() }) end, { desc = "Open Neotree", remap = true }) ---- -- Fixes ---- -- Proper Wrap Navigation map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) map({ "n", "x" }, "", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) map({ "n", "x" }, "", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -- Auto Re-highlight After Indent map("v", "<", "", ">gv") -- Saner Movement of nN map("n", "n", "'Nn'[v:searchforward].'zv'.'zz'", { expr = true, desc = "Next search result" }) map("x", "n", "'Nn'[v:searchforward].'zz'", { expr = true, desc = "Next search result" }) map("o", "n", "'Nn'[v:searchforward].'zz'", { expr = true, desc = "Next search result" }) map("n", "N", "'nN'[v:searchforward].'zv'.'zz'", { expr = true, desc = "Prev search result" }) map("x", "N", "'nN'[v:searchforward].'zz'", { expr = true, desc = "Prev search result" }) map("o", "N", "'nN'[v:searchforward].'zz'", { expr = true, desc = "Prev search result" }) -- Terminal Mappings map("t", "", "", { desc = "Enter Normal Mode" }) map("t", "", "wincmd h", { desc = "Go to left window" }) map("t", "", "wincmd j", { desc = "Go to lower window" }) map("t", "", "wincmd k", { desc = "Go to upper window" }) map("t", "", "wincmd l", { desc = "Go to right window" }) map("t", "", "close", { desc = "Hide Terminal" }) map("t", "", "close", { desc = "which_key_ignore" })