local map = vim.keymap.set map("i", "", "^i", { desc = "Beginning of line | general" }) map("i", "", "", { desc = "End of line | general" }) map("i", "", "", { desc = "Move left | general" }) map("i", "", "", { desc = "Move right | general" }) map("i", "", "", { desc = "Move down | general" }) map("i", "", "", { desc = "Move up | general" }) map("n", "", "noh", { desc = "Clear highlights | general" }) map("n", "", "h", { desc = "Window left | general" }) map("n", "", "l", { desc = "Window right | general" }) map("n", "", "j", { desc = "Window down | general" }) map("n", "", "k", { desc = "Window up | general" }) map("n", "", "w", { desc = "Save file | general" }) map("n", "", "%y+", { desc = "Copy whole file | general" }) map("n", "n", "set nu!", { desc = "Toggle line number | general" }) map("n", "rn", "set rnu!", { desc = "Toggle relative number | general" }) map("n", "b", "enew", { desc = "New buffer | general" }) map("n", "ch", "NvCheatsheet", { desc = "Mapping cheatsheet | general" }) map("n", "fm", function() vim.lsp.buf.format { async = true } end, { desc = "LSP formatting | lsp" }) vim.keymap.set("n", "lf", vim.diagnostic.open_float, { desc = "floating diagnostics | lsp" }) vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "prev diagnostic | lsp" }) vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic | lsp" }) vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "diagnostic loclist | lsp" }) -- Mappings for terminal mode map( "t", "", vim.api.nvim_replace_termcodes("", true, true, true), { desc = "Escape terminal mode | general" } ) -- Mappings for M.tabufline if vim.g.tabufline_maps then map("n", "", function() require("nvchad.tabufline").tabuflineNext() end, { desc = "Goto next buffer | tabufline" }) map("n", "", function() require("nvchad.tabufline").tabuflinePrev() end, { desc = "Goto prev buffer | tabufline" }) map("n", "x", function() require("nvchad.tabufline").close_buffer() end, { desc = "Close buffer | tabufline" }) end if vim.g.comment_maps then map("n", "/", function() require("Comment.api").toggle.linewise.current() end, { desc = "Toggle comment | comment" }) map( "v", "/", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", { desc = "Toggle comment | comment" } ) end if vim.g.nvimtree_maps then map("n", "", "NvimTreeToggle", { desc = "Toggle nvimtree | nvimtree" }) map("n", "e", "NvimTreeFocus", { desc = "Focus nvimtree | nvimtree" }) end if vim.g.telescope_maps then map("n", "fw", "Telescope live_grep", { desc = "Live grep | telescope" }) map("n", "fb", "Telescope buffers", { desc = "Find buffers | telescope" }) map("n", "fh", "Telescope help_tags", { desc = "Help page | telescope" }) map("n", "fo", "Telescope oldfiles", { desc = "Find oldfiles | telescope" }) map( "n", "fz", "Telescope current_buffer_fuzzy_find", { desc = "Find in current buffer | telescope" } ) map("n", "cm", "Telescope git_commits", { desc = "Git commits | telescope" }) map("n", "gt", "Telescope git_status", { desc = "Git status | telescope" }) map("n", "pt", "Telescope terms", { desc = "Pick hidden term | telescope" }) map("n", "th", "Telescope themes", { desc = "Nvchad themes | telescope" }) map("n", "ff", "Telescope find_files", { desc = "Find files | telescope" }) map( "n", "fa", "Telescope find_files follow=true no_ignore=true hidden=true", { desc = "Find all | telescope" } ) end -- Mappings for M.terminal if vim.g.terminal_maps then map("n", "h", function() require("nvchad.term").new { pos = "sp", size = 0.3 } end, { desc = "New horizontal term | terminal" }) map("n", "v", function() require("nvchad.term").new { pos = "vsp", size = 0.3 } end, { desc = "New vertical term | terminal" }) map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 } end, { desc = "Toggleable vertical term | terminal" }) map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 } end, { desc = "New horizontal term | terminal" }) map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "float", id = "floatTerm" } end, { desc = "Toggleable Floating term | terminal" }) map("t", "", function() local win = vim.api.nvim_get_current_win() vim.api.nvim_win_close(win, true) end, { desc = "Close term in terminal mode | terminal" }) end if vim.g.whichkey_maps then map("n", "wK", ":WhichKey ", { desc = "Which-key all keymaps | whichkey" }) map("n", "wk", function() vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ") end, { desc = "Which-key query lookup | whichkey" }) end if vim.g.blankline_maps then 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 = "Jump to current context | blankline" }) end require "custom.mappings"