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" }) -- global lsp mappings map("n", "fm", function() vim.lsp.buf.format { async = true } end, { desc = "LSP formatting | lsp" }) map("n", "lf", vim.diagnostic.open_float, { desc = "floating diagnostics | lsp" }) map("n", "[d", vim.diagnostic.goto_prev, { desc = "prev diagnostic | lsp" }) map("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic | lsp" }) map("n", "q", vim.diagnostic.setloclist, { desc = "diagnostic loclist | lsp" }) -- tabufline 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" }) 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" } ) map("n", "", "NvimTreeToggle", { desc = "Toggle nvimtree | nvimtree" }) map("n", "e", "NvimTreeFocus", { desc = "Focus nvimtree | nvimtree" }) 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" } ) -- terminal map("t", "", "", { desc = "Escape terminal mode | terminal" }) 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" }) -- whichkey 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" }) 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" }) pcall(require, "custom.mappings")