map = function(m, k, v) vim.keymap.set(m, k, v, { silent = true }) end -- Fix * (Keep the cursor position, don't move to next match) map("n", "*", "*N") -- Move line up and down in NORMAL and VISUAL modes map("n", "", "move .+1") map("n", "", "move .-2") map("x", "", ":move '>+1gv=gv") map("x", "", ":move '<-2gv=gv") -- Keep cursor position map("n", "J", "mzJ`z") -- Keep cursur in center map("n", "", "zz") map("n", "", "zz") map("n", "n", "nzzzv") map("n", "N", "Nzzzv") -- Remove to void (and paste) map("n", "d", "\"_d") map("v", "d", "\"_d") map("x", "p", "\"_dP") -- Format map("n", "i", function() vim.lsp.buf.format() end) -- Edit word map("n", "s", [[:%s/\<\>//gI]]) -- Make executable map("n", "x", "!chmod +x %") -- map("n", "", ":Files") map("n", "", ":!compile %") -- Move to the next/previous buffer -- map("n", "[", "bp") -- map("n", "]", "bn") -- Move to last buffer -- map("n", """", "b#") -- Telescope binds local Telescope = setmetatable({}, { __index = function(_, k) if vim.bo.filetype == "NvimTree" then vim.cmd.wincmd("l") end return require("telescope.builtin")[k] end, }) -- Help map("n", "fh", Telescope.help_tags) -- Files with match map("n", "ff", Telescope.live_grep) -- Project files map("n", "fp", Telescope.find_files) -- Changed git files map("n", "fc", Telescope.git_status) -- Git files map("n", "fg", function() local ok = pcall(Telescope.git_files, { show_untracked = true }) if not ok then Telescope.find_files() end end) -- Highlighted comments map("n", "ft", "TodoTelescope") -- Hacky update thing --[[ map("n", "u", function() local ok = pcall(vim.cmd.PackerSync) if ok then ok = pcall(vim.cmd.PackerCompile) end if ok then ok = pcall(vim.cmd.TSUpdate) end if ok then pcall(vim.cmd.Mason) end end) ]] exp = {} exp.map = map