local map = vim.keymap.set map("n", "", "noh", { desc = "General Clear highlights" }) map("n", "", "w", { desc = "File Save" }) map("n", "", "%y+", { desc = "File Copy whole" }) map("n", "n", "set nu!", { desc = "Toggle Line number" }) map("n", "rn", "set rnu!", { desc = "Toggle Relative number" }) map("n", "ch", "NvCheatsheet", { desc = "Toggle NvCheatsheet" }) map("n", "fm", function() require("conform").format { lsp_fallback = true } end, { desc = "Format Files" }) -- lsp mappings map({ "n", "v" }, "", "Lspsaga code_action", { desc = "LSP code action" }) map({ "n", "v" }, "", "Lspsaga peek_definition", { desc = "LSP peek definition" }) map({ "n", "v" }, "", "Lspsaga peek_type_definition", { desc = "LSP peek type definition" }) map({ "n", "v" }, "", "Lspsaga goto_definition", { desc = "LSP goto definition" }) map({ "n", "v" }, "", "Lspsaga goto_type_definition", { desc = "LSP goto type definition" }) map({ "n", "v" }, "", "Lspsaga rename ++project", { desc = "LSP rename" }) map({ "n", "v" }, "", "Lspsaga diagnostic_jump_next", { desc = "LSP diagnostic next" }) map({ "n", "v" }, "", "Lspsaga diagnostic_jump_prev", { desc = "LSP diagnostic previous" }) -- tabufline map("n", "b", "enew", { desc = "Buffer New" }) map("n", "", function() require("nvchad.tabufline").next() end, { desc = "Buffer Goto next" }) map("n", "", function() require("nvchad.tabufline").prev() end, { desc = "Buffer Goto prev" }) map("n", "x", function() require("nvchad.tabufline").close_buffer() end, { desc = "Buffer Close" }) map("n", "t", "tabnew", { desc = "Tab New" }) -- Comment map("n", "/", "gcc", { desc = "Comment toggle", remap = true }) map("v", "/", "gc", { desc = "Comment toggle", remap = true }) -- Spider nvim movement map({ "n", "v" }, "w", "lua require('spider').motion('w')", {desc = "Spider Move to next word"}) map({ "n", "v" }, "b", "lua require('spider').motion('b')", {desc = "Spider Move to previous word"}) map({ "n", "v" }, "e", "lua require('spider').motion('e')", {desc = "Spider Move to end of word"}) -- nvimtree map("n", "", "NvimTreeToggle", { desc = "Nvimtree Toggle window" }) map("n", "e", "NvimTreeFocus", { desc = "Nvimtree Focus window" }) -- telescope map("n", "fw", "Telescope live_grep", { desc = "Telescope Live grep" }) map("n", "fb", "Telescope buffers", { desc = "Telescope Find buffers" }) map("n", "fh", "Telescope help_tags", { desc = "Telescope Help page" }) map("n", "fo", "Telescope oldfiles", { desc = "Telescope Find oldfiles" }) map("n", "fz", "Telescope current_buffer_fuzzy_find", { desc = "Telescope Find in current buffer" }) map("n", "cm", "Telescope git_commits", { desc = "Telescope Git commits" }) map("n", "gt", "Telescope git_status", { desc = "Telescope Git status" }) map("n", "pt", "Telescope terms", { desc = "Telescope Pick hidden term" }) map("n", "th", "Telescope themes", { desc = "Telescope Nvchad themes" }) map("n", "ff", "Telescope find_files", { desc = "Telescope Find files" }) map( "n", "fa", "Telescope find_files follow=true no_ignore=true hidden=true", { desc = "Telescope Find all files" } ) -- terminal map("t", "", "", { desc = "Terminal Escape terminal mode" }) map("t", "", function() local win = vim.api.nvim_get_current_win() vim.api.nvim_win_close(win, true) end, { desc = "Terminal Close term in terminal mode" }) -- new terminals map("n", "h", function() require("nvchad.term").new { pos = "sp", size = 0.4 } end, { desc = "Terminal New horizontal term" }) map("n", "v", function() require("nvchad.term").new { pos = "vsp", size = 0.5 } end, { desc = "Terminal New vertical window" }) -- toggleable -- map({ "n", "t" }, "", function() -- require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 } -- end, { desc = "Terminal Toggleable vertical term" }) -- -- map({ "n", "t" }, "", function() -- require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.3 } -- end, { desc = "Terminal New horizontal term" }) -- -- map({ "n", "t" }, "", function() -- require("nvchad.term").toggle { pos = "float", id = "floatTerm" } -- end, { desc = "Terminal Toggle Floating term" }) -- whichkey map("n", "wK", "WhichKey ", { desc = "Whichkey all keymaps" }) map("n", "wk", function() vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ") end, { desc = "Whichkey query lookup" }) -- blankline map("n", "cc", function() local config = { scope = {} } config.scope.exclude = { language = {}, node_type = {} } config.scope.include = { node_type = {} } local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config) if node then local start_row, _, end_row, _ = node:range() if start_row ~= end_row then vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 }) vim.api.nvim_feedkeys("_", "n", true) end end end, { desc = "Blankline Jump to current context" }) -- copilotchat map({ "n", "v" }, "ccp", function() local actions = require("CopilotChat.actions") require("CopilotChat.integrations.telescope").pick(actions.prompt_actions()) end, { desc = "CopilotChat - Prompt actions" }) map({ "n", "v" }, "ccq", function() local input = vim.fn.input("Quick Chat: ") if input ~= "" then require("CopilotChat").ask(input, { selection = require("CopilotChat.select").buffer }) end end, { desc = "CopilotChat - Quick chat" }) map({ "n", "v" }, "ccf", function() require("CopilotChat").ask("Fix this, using the lsp diagnostics if needed", { selection = require("CopilotChat.select").visual }) end, { desc = "CopilotChat - Fix this" }) -- menu -- vim.keymap.set("n", "", function() -- require("menu").open("default") -- end, {}) -- -- vim.keymap.set("n", "", function() -- vim.cmd.exec '"normal! \\"' -- -- local options = vim.bo.ft == "NvimTree" and "nvimtree" or "default" -- require("menu").open(options, { mouse = true }) -- end, {}) -- Custom mappings map("n", "", ":", { desc = "Enter command mode" }) map({ "n", "v" }, "j", "h", { desc = "Move left" }) map({ "n", "v" }, "k", "j", { desc = "Move down" }) map({ "n", "v" }, "l", "k", { desc = "Move up" }) map({ "n", "v" }, "m", "l", { desc = "Move right" }) map("n", "", "h", { desc = "Move the cursor to the left window" }) map("n", "", "j", { desc = "Move the cursor to the bottom window" }) map("n", "", "k", { desc = "Move the cursor to the upper window" }) map("n", "", "l", { desc = "Move the cursor to the right window" }) map("n", "", "+", { desc = "Enlarge window upwards" }) map("n", "", "-", { desc = "Enlarge window downwards" }) map("n", "", ">", { desc = "Enlarge window to the left" }) map("n", "", "<", { desc = "Enlarge window to the rigth" }) map("n", "o", "o") map("n", "O", "O") map("n", "n", "nzz") map("n", "N", "Nzz") map({ "n", "v" }, "y", "\"+y") map("n", "yy", "\"+yy") map({ "n", "v" }, "Y", "\"+yg_") map({ "n", "v" }, "p", "\"+p") map({ "n", "v" }, "P", "\"+P") map("n", "a", function() require("treesj").toggle() end, { desc = "Extends or retracts an instruction block" }) map({ "n", "v" }, "gb", "Gitsigns blame", { desc = "Git blame" }) map("i", "jj", "", { desc = "Enter normal mode" }) map("i", "", "ddi", { desc = "Delete a line" }) map("i", "", "^i", { desc = "Move Beginning of line" }) map("i", "", "", { desc = "Move End of line" }) map("i", "", "", { desc = "Move Left" }) map("i", "", "", { desc = "Move Right" }) map("i", "", "", { desc = "Move Down" }) map("i", "", "", { desc = "Move Up" }) -- Disable mappings -- local nomap = vim.keymap.del -- LSP unmappings are set in configs/lspconfig.lua -- nomap("n", "h") -- nomap("n", "j") -- nomap("n", "k") -- nomap("n", "l") -- nomap("n", "") -- nomap("n", "") -- nomap("n", "") -- nomap("n", "") -- nomap("n", "") -- nomap("v", "h") -- nomap("v", "j") -- nomap("v", "k") -- nomap("v", "l")