local map = vim.keymap.set 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" }) map("n", "", "noh", { desc = "general clear highlights" }) map("n", "", "h", { desc = "switch window left" }) map("n", "", "l", { desc = "switch window right" }) map("n", "", "j", { desc = "switch window down" }) map("n", "", "k", { desc = "switch window up" }) 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" }) -- global lsp mappings map("n", "ds", vim.diagnostic.setloclist, { desc = "lsp diagnostic loclist" }) -- 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" }) -- Comment map("n", "/", "gcc", { desc = "comment toggle", remap = true }) map("v", "/", "gc", { desc = "comment toggle", remap = true }) -- 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", "ma", "Telescope marks", { desc = "telescope find marks" }) 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" }) -- new terminals map("n", "h", function() require("nvchad.term").new { pos = "sp" } end, { desc = "terminal new horizontal term" }) map("n", "v", function() require("nvchad.term").new { pos = "vsp" } end, { desc = "terminal new vertical window" }) -- toggleable map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm" } end, { desc = "terminal toggleable vertical term" }) map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" } 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" })