local map = vim.keymap.set local opts = { noremap = true, silent = true } map("n", "", "nohlsearch") -- Diagnostic keymaps -- map("n", "q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" }) -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- for people to discover. Otherwise, you normally need to press , which -- is not what someone will guess without a bit more experience. -- -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping -- or just use to exit terminal mode map("t", "", "", { desc = "Exit terminal mode" }) map("n", "-", "Oil ", { desc = "Open parent directory" }) -- Create a new buffer map("n", "b", " enew ", { desc = "new buffer" }) map("n", "U", " Telescope undo", { desc = "Telescope Undo" }) -- Toggle comment map("n", "/", function() require("Comment.api").toggle.linewise.current() end, { desc = "Toggle comment line" }) map("n", "cb", function() require("Comment.api").toggle.blockwise.current() end, { desc = "Toggle comment block" }) map( "v", "/", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", { desc = "Toggle comment line" } ) map("n", "cr", "!cc -g % -o %:r && ./%:r", { desc = "Compile and run C code" }) -- ============================================ -- GitHub Copilot Keybindings -- ============================================ -- Copilot suggestions (in insert mode) -- Note: These are handled by the plugin config above, but listed here for reference -- Accept suggestion (Alt+l) -- Next suggestion (Alt+]) -- Previous suggestion (Alt+[) -- Dismiss suggestion (Ctrl+]) -- Copilot Chat - Quick Actions map("n", "jj", "CopilotChatToggle", { desc = "Toggle Copilot Chat" }) map("n", "jo", "CopilotChat", { desc = "Open Copilot Chat" }) map("n", "jx", "CopilotChatClose", { desc = "Close Copilot Chat" }) map("n", "jr", "CopilotChatReset", { desc = "Reset Chat History" }) -- Copilot Chat - Code Actions (work in normal and visual mode) map({ "n", "v" }, "je", "CopilotChatExplain", { desc = "Explain Code" }) map({ "n", "v" }, "jt", "CopilotChatTests", { desc = "Generate Tests" }) map({ "n", "v" }, "jf", "CopilotChatFix", { desc = "Fix Code" }) map({ "n", "v" }, "jO", "CopilotChatOptimize", { desc = "Optimize Code" }) map({ "n", "v" }, "jd", "CopilotChatDocs", { desc = "Generate Documentation" }) map({ "n", "v" }, "jV", "CopilotChatReview", { desc = "Review Code" }) -- Copilot Chat - Git Integration map("n", "jc", "CopilotChatCommit", { desc = "Generate Commit Message" }) map("n", "jC", "CopilotChatCommitStaged", { desc = "Commit Message (Staged)" }) -- Copilot Chat - Quick Question map("n", "jq", function() local input = vim.fn.input("Quick Chat: ") if input ~= "" then require("CopilotChat").ask(input) end end, { desc = "Quick Question to Copilot" }) -- Copilot Chat - Visual Mode map("v", "jv", ":CopilotChatVisual ", { desc = "Chat with Selection" }) map("v", "ji", ":CopilotChatInline", { desc = "Inline Chat" }) -- Copilot Chat - Buffer Context map("n", "jb", function() local input = vim.fn.input("Ask Copilot (Buffer Context): ") if input ~= "" then require("CopilotChat").ask(input, { selection = require("CopilotChat.select").buffer }) end end, { desc = "Ask About Entire Buffer" }) -- Copilot Chat - Diagnostic Help map("n", "jD", function() require("CopilotChat").ask("Help with diagnostics", { selection = require("CopilotChat.select").diagnostics, }) end, { desc = "Fix Diagnostics with Copilot" }) -- Copilot Panel Toggle (alternative suggestion view) map("n", "jp", "Copilot panel", { desc = "Open Copilot Panel" }) -- line numbers map("n", "nn", " set nu! ", { desc = "Toggle line number" }) map("n", "nr", " set rnu! ", { desc = "Toggle relative number" }) -- TIP: Disable arrow keys in normal mode map("n", "", 'echo "Use h to move!!"') map("n", "", 'echo "Use l to move!!"') map("n", "", 'echo "Use k to move!!"') map("n", "", 'echo "Use j to move!!"') map("n", "wk", "WhichKey", { desc = "Which-Key all keymaps" }) map("n", "wK", function() local input = vim.fn.input("WhichKey: ") vim.cmd("WhichKey" .. input) end, { desc = "Which-Key query lookup" }) map("n", "gs", "Git status", { desc = "Git status" }) -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows -- -- See `:help wincmd` for a list of all window commands map("n", "", "", { desc = "Move focus to the left window" }) map("n", "", "", { desc = "Move focus to the right window" }) map("n", "", "", { desc = "Move focus to the lower window" }) map("n", "", "", { desc = "Move focus to the upper window" }) map("n", "", function() require("nvchad.tabufline").prev() end, opts) map("n", "", function() require("nvchad.tabufline").next() end, opts) map("n", "q", function() require("nvchad.tabufline").close_buffer() end, opts) map("n", "", ":m .+1==", opts) map("n", "", ":m .-2==", opts) map("i", "", ":m .+1==gi", opts) map("i", "", ":m .-2==gi", opts) map("v", "", ":m '>+1gv=gv", opts) map("v", "", ":m '<-2gv=gv", opts) map("n", "cc", function() local ok, start = require("indent_blankline.utils").get_current_context( vim.g.indent_blankline_context_patterns, vim.g.indent_blankline_use_treesitter_scope ) if ok then vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 }) vim.cmd([[normal! _]]) end end, { desc = "Jump to current context" }) -- greatest remap ever map("x", "p", [["_dP]]) map("n", "xx", "!chmod +x %", { silent = true }) map("i", "", "", opts) -- next greatest remap ever : asbjornHaland map({ "n", "v" }, "y", [["+y]]) vim.keymap.set("n", "Q", "") vim.keymap.set("n", "Q!", "") vim.keymap.set("n", "Wq", "") map("n", "Y", [["+Y]]) map("n", "C", " Cheat ") map("n", "fa", " lua require('fzf-lua').files() ", { desc = "FZF find files" }) map("n", "ff", " lua require('fzf-lua').files() ", { desc = "FZF find files" }) map("n", "fq", " lua require('fzf-lua').quickfix() ", { desc = "FZF quickfix" }) map("n", "fb", " lua require('fzf-lua').buffers() ", { desc = "FZF find buffers" }) map("n", "fZ", " lua require('fzf-lua').lgerp_curbuf() ", { desc = "FZF Live grep current buffer" }) map("n", "fd", " lua require('fzf-lua').oldfiles() ", { desc = "FZF opened files history" }) map("n", "fm", " lua require('fzf-lua').marks() ", { desc = "FZF marks" }) map("n", "fw", " lua require('fzf-lua').live_grep() ", { desc = "FZF live grep" }) map("n", "fg", " lua require('fzf-lua').git_Commits() ", { desc = "FZF Git commits" }) map("n", "fG", " lua require('fzf-lua').git_bcommits() ", { desc = "FZF Git commits" }) map("n", "fs", " lua require('fzf-lua').git_status() ", { desc = "FZF Git commits" }) map("n", "fp", " lua require('fzf-lua').manpages() ", { desc = "FZF Manpages" })