-- maps are automatically loaded on the VeryLazy event -- Default maps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/maps.lua -- Add any additional maps here local Util = require("lazyvim.util") local function map(mode, lhs, rhs, opts) local keys = require("lazy.core.handler").handlers.keys ---@cast keys LazyKeysHandler -- do not create the map if a lazy keys handler exists if not keys.active[keys.parse({ lhs, mode = mode }).id] then opts = opts or {} opts.silent = opts.silent ~= false vim.keymap.set(mode, lhs, rhs, opts) end end local opts = { noremap = true, silent = true } local term_opts = { silent = true } -- debug map("n", "", ':lua require("dap").toggle_breakpoint()', opts) map("n", "", ':lua require("dap").step_over()', opts) map("n", "", ':lua require("dap").step_into()', opts) map("n", "", ':lua require("dapui").toggle() :lua require("dap").continue() ', opts) map("n", "", ':lua require("dap").continue()', opts) map("n", "", ':lua require("dap").close() :lua require("dapui").toggle()', opts) -- file tree map("n", "f", ":Neotree action=focus toggle=true", opts) -- toggle terminal map("n", "", ":lua require('toggleterm').toggle(1)", opts) -- tab switching map("n", "", ":BufferLineCyclePrev", opts) map("n", "", ":BufferLineCycleNext", opts) -- formatting map("n", "", ":lua vim.lsp.buf.format { async = true }", opts) map("n", "a", ":Telescope lsp_definitions", opts) map("n", "s", ":Telescope lsp_references", opts) map("n", "d", ":Telescope lsp_type_definitions", opts) map("n", "f", ":Telescope lsp_implementations", opts) map("n", "q", ":lua vim.lsp.buf.code_action()", opts) map("n", "w", ":lua vim.lsp.buf.signature_help()", opts) map("n", "e", ":lua vim.lsp.buf.hover()", opts) map("n", "r", ":lua vim.lsp.buf.rename()", opts) map("n", "gq", ":lua require('telescope.builtin').git_commits()", opts) map("n", "gw", ":lua require('telescope.builtin').git_bcommits()", opts) map("n", "ge", ":lua require('telescope.builtin').git_branches()", opts) map("n", "gr", ":lua require('telescope.builtin').git_status()", opts) map("n", "ga", ":lua require('telescope.builtin').git_stash()", opts) -- window switching function _G.set_terminal_maps() local opts = { buffer = 0 } vim.keymap.set("t", "", [[]], opts) vim.keymap.set("t", "jk", [[]], opts) vim.keymap.set("t", "", [[wincmd h]], opts) vim.keymap.set("t", "", [[wincmd j]], opts) vim.keymap.set("t", "", [[wincmd k]], opts) vim.keymap.set("t", "", [[wincmd l]], opts) end -- if you only want these mappings for toggle term use term://*toggleterm#* instead vim.cmd("autocmd! TermOpen term://* lua set_terminal_maps()") map("n", "", ":wincmd h", opts) map("n", "", ":wincmd j", opts) map("n", "", ":wincmd k", opts) map("n", "", ":wincmd l", opts) -- harpoon man map("n", "", ":lua require('harpoon.ui').nav_file(1)", opts) map("n", "", ":lua require('harpoon.ui').nav_file(2)", opts) map("n", "", ":lua require('harpoon.ui').nav_file(3)", opts) map("n", "fma", ":lua require('harpoon.mark').add_file()", opts) map("n", "fmd", ":lua require('harpoon.mark').remove_file()", opts) -- telescope map("n", "fb", ":Telescope file_browser", {}) map("n", "fc", ":Cheatsheet", {}) map("n", "ff", ":lua require('telescope.builtin').find_files()", {}) map("n", "fg", ":lua require('telescope.builtin').live_grep()", {}) map("n", "fh", ":lua require('telescope.builtin').help_tags()", {}) map("n", "fp", ":lua require'telescope'.extensions.project.project{}", { noremap = true, silent = true }) map("n", "fm", ":Telescope harpoon marks", { noremap = true, silent = true }) vim.keymap.set("n", "z", ":lua require('telescope').extensions.zoxide.list{}") -- trouble map("n", "", "TroubleToggle", term_opts) -- gitui map("n", "gg", function() Util.float_term({ "gitui" }, { cwd = Util.get_root() }) end, { desc = "gitui (root dir)" }) map("n", "gG", function() Util.float_term({ "gitui" }) end, { desc = "gitui (cwd)" })