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" }) -- global lsp mappings map("n", "fm", function() vim.lsp.buf.format { async = true } end, { desc = "Lsp formatting" }) map("n", "lf", vim.diagnostic.open_float, { desc = "Lsp floating diagnostics" }) map("n", "[d", vim.diagnostic.goto_prev, { desc = "Lsp prev diagnostic" }) map("n", "]d", vim.diagnostic.goto_next, { desc = "Lsp next diagnostic" }) map("n", "q", 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", "/", function() require("Comment.api").toggle.linewise.current() end, { desc = "Comment Toggle" }) map( "v", "/", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", { desc = "Comment Toggle" } ) -- 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("n", "h", function() require("nvchad.term").new { pos = "sp", size = 0.3 } end, { desc = "Terminal New horizontal term" }) map("n", "v", function() require("nvchad.term").new { pos = "vsp", size = 0.3 } end, { desc = "Terminal New vertical term" }) 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.2 } end, { desc = "Terminal New horizontal term" }) map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "float", id = "floatTerm" } end, { desc = "Terminal Toggle Floating term" }) 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" }) -- 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" }) require "custom.mappings"