- Remove locally-developed or rarely-used plugin packages (codetyper, curls, edgy, flash) to reduce maintenance surface, external deps, and startup cost; these were local/optional and caused complexity. - Clean up stale/keymap docs and small duplicate or experimental files (keymaps/README.md, sudoku keymaps). - Apply targeted refactors to core modules for readability, robustness, and to align Java/DAP/Copilot integrations with local environment. - Removed plugin modules: - lua/cargdev/plugins/codetyper.lua (deleted) - lua/cargdev/plugins/curls.lua (deleted) - lua/cargdev/plugins/edgy.lua (deleted) - lua/cargdev/plugins/flash.lua (deleted) - Added .codetyper to .gitignore - Java / JDTLS: - ftplugin/java.lua: pin jdtls java executable to JDK 25, switch to mac_arm config, enable LSP formatter and declare multiple runtimes (JavaSE-17, JavaSE-25). - Notifications & startup UX: - lua/cargdev/core/function/notification_manager.lua: large refactor — use local aliases (api, cmd, loop, opt), improved docs, dashboard-aware handling, nvim-notify fallback, safer tracking and cleanup of notifications. - Utilities & monitors: - lua/cargdev/core/function/performance_monitor.lua: use local references, better notify usage and docs. - lua/cargdev/core/function/project_commands.lua: add docs, use local api/fn/notify, clearer RunProject/DebugProject commands. - Terminal helper: - lua/cargdev/core/function/openTerminal.lua: add module docs and small refactor to use local cmd/api aliases and expose keymap. - Keymaps & docs: - Removed stale keymaps README (lua/cargdev/core/keymaps/README.md). - Reworked many keymap files: docstrings, renamed/moved mappings to avoid conflicts, moved DAP mappings into dap plugin config, removed/disabled experimental mappings (see files under lua/cargdev/core/keymaps/*). - Adjusted quick keybindings and prefixes to reduce overlaps. - Plugins & integrations: - lua/cargdev/plugins/formatting.lua: disabled google-java-format fallback for java (prefer JDTLS). - lua/cargdev/plugins/dap.lua: added additional DAP configs (Bun launch, attach helper), moved/registered dap keymaps here. - lua/cargdev/plugins/copilot.lua: reorganized Copilot/Copilot-cmp/CopilotChat config and added copilot source to nvim-cmp. - lua/cargdev/plugins/nvim-cmp.lua: added copilot source and small formatting tweak.
117 lines
5.6 KiB
Lua
117 lines
5.6 KiB
Lua
--- Personal keymaps — custom workflow shortcuts.
|
|
--- Includes text selection helpers, file management (save, quit, source),
|
|
--- number increment/decrement, buffer management with smart close via
|
|
--- snacks.bufdelete, coding shortcuts (React import, semicolons, commas,
|
|
--- console.log), Copilot Chat commands, clipboard HTML-to-Markdown paste,
|
|
--- and quickfix/location list navigation.
|
|
--- @module keymaps.personal
|
|
|
|
local keymap = vim.keymap
|
|
|
|
-- =============================================================================
|
|
-- PERSONAL KEYMAPS (ORIGINAL WORKFLOW)
|
|
-- =============================================================================
|
|
|
|
--- Select the entire file contents (visual mode).
|
|
keymap.set("n", "<leader>u", function()
|
|
vim.cmd("normal! ggVG$")
|
|
end, { desc = "Select the whole file" })
|
|
|
|
--- Duplicate the current line below.
|
|
keymap.set("n", "<leader>4", function()
|
|
-- Copy current line and paste below
|
|
vim.cmd("normal! yy")
|
|
vim.cmd("normal! p")
|
|
end, { desc = "Copy the entire line and paste just below" })
|
|
|
|
--- File management — save, quit, force quit, source, and clear search.
|
|
keymap.set("n", "<leader>w", ":w<CR>", { desc = "Save the current file" })
|
|
keymap.set("n", "<leader>xa", ":xa<CR>", { desc = "Save and close all the files" })
|
|
keymap.set("n", "<leader>q", ":q<CR>", { desc = "Quit" })
|
|
keymap.set("n", "<leader>so", ":source %<CR>", { desc = "Reload nvim" })
|
|
keymap.set("n", "<leader>no", ":noh <CR>", { desc = "Reset search a word" })
|
|
|
|
--- Increment/decrement the number under the cursor.
|
|
keymap.set("n", "<leader>+", "<C-a>", { desc = "Increment number" })
|
|
keymap.set("n", "<leader>-", "<C-x>", { desc = "Decrement number" })
|
|
|
|
-- Window management keymaps are centralized in lua/cargdev/core/keymaps/window.lua
|
|
|
|
--- Re-indent the entire file using Neovim's built-in `=` operator.
|
|
keymap.set("n", "<leader>sy", "gg=G<CR>", { desc = "Format current file" })
|
|
|
|
--- Fast scroll — 10 lines at a time with Ctrl+E / Ctrl+Y.
|
|
keymap.set("n", "<C-e>", "10<C-e>", { noremap = true, silent = true })
|
|
keymap.set("n", "<C-y>", "10<C-y>", { noremap = true, silent = true })
|
|
|
|
--- Close the current buffer with a confirmation prompt if modified.
|
|
keymap.set("n", "<leader>bd", function()
|
|
if vim.bo.modified then
|
|
vim.ui.select({ "Save & Close", "Discard & Close", "Cancel" }, {
|
|
prompt = "Buffer has unsaved changes:",
|
|
}, function(choice)
|
|
if choice == "Save & Close" then
|
|
vim.cmd("w")
|
|
vim.cmd("bd")
|
|
elseif choice == "Discard & Close" then
|
|
vim.cmd("bd!")
|
|
end
|
|
end)
|
|
else
|
|
vim.cmd("bd")
|
|
end
|
|
end, { desc = "Buffer: Close (safe)" })
|
|
|
|
--- Force close the current buffer, discarding unsaved changes.
|
|
keymap.set("n", "<leader>bD", ":db!<CR>", { desc = "Buffer: Force close" })
|
|
|
|
--- Buftabline navigation — Ctrl+P next buffer, Ctrl+N previous buffer.
|
|
keymap.set("n", "<C-p>", ":bnext<CR>", { noremap = true, silent = true })
|
|
keymap.set("n", "<C-n>", ":bprev<CR>", { noremap = true, silent = true })
|
|
|
|
--- Coding shortcuts — React import, trailing comma/semicolon, run with Node.
|
|
keymap.set(
|
|
"n",
|
|
"<leader>re",
|
|
"ggOimport<space>React<space>from<space>'react';<esc>0",
|
|
{ desc = "Type import react from 'react' at the top of the file" }
|
|
)
|
|
keymap.set("n", "<leader>,", "$a,<ESC>", { desc = "Adding ',' at the end of the line" })
|
|
keymap.set("n", "<leader>;", "$a;<ESC>", { desc = "Adding ';' at the end of the line" })
|
|
keymap.set("n", "<leader>xr", ":!node %<CR>", { desc = "Run file with node" })
|
|
|
|
-- Resize splits keymaps are centralized in lua/cargdev/core/keymaps/window.lua
|
|
|
|
--- Copilot Chat — rename, explain, review, fix, optimize, and generate docs.
|
|
keymap.set("v", "<leader>zn", ":CopilotChatRename<CR>", { desc = "Rename variable (Copilot Chat)" })
|
|
keymap.set("n", "<leader>zc", ":CopilotChat<CR>", { desc = "Open Copilot Chat" })
|
|
keymap.set("v", "<leader>ze", ":CopilotChatExplain<CR>", { desc = "Explain code (Copilot Chat)" })
|
|
keymap.set("v", "<leader>zr", ":CopilotChatReview<CR>", { desc = "Review code (Copilot Chat)" })
|
|
keymap.set("v", "<leader>zf", ":CopilotChatFix<CR>", { desc = "Fix code issues (Copilot Chat)" })
|
|
keymap.set("v", "<leader>zo", ":CopilotChatOptimize<CR>", { desc = "Optimize code (Copilot Chat)" })
|
|
keymap.set("v", "<leader>zd", ":CopilotChatDocs<CR>", { desc = "Generate docs (Copilot Chat)" })
|
|
|
|
--- Paste HTML from the system clipboard as GitHub-Flavored Markdown (via pandoc).
|
|
--- TODO: Fix this keymap
|
|
-- keymap.set("n", "<leader>p", function()
|
|
-- vim.cmd("read !pbpaste -Prefer html | pandoc -f html -t gfm")
|
|
-- end, { desc = "Paste HTML clipboard as Markdown" })
|
|
|
|
-- =============================================================================
|
|
-- QUICKFIX NAVIGATION (under <leader>x for Trouble/Diagnostics group)
|
|
-- =============================================================================
|
|
|
|
--- Quickfix list navigation — next, previous, open, close, first, last.
|
|
keymap.set("n", "<leader>xn", ":cnext<CR>zz", { desc = "Quickfix: Next item" })
|
|
keymap.set("n", "<leader>xp", ":cprev<CR>zz", { desc = "Quickfix: Previous item" })
|
|
keymap.set("n", "<leader>xo", ":copen<CR>", { desc = "Quickfix: Open list" })
|
|
keymap.set("n", "<leader>xq", ":cclose<CR>", { desc = "Quickfix: Close list" })
|
|
keymap.set("n", "<leader>xf", ":cfirst<CR>zz", { desc = "Quickfix: First item" })
|
|
keymap.set("n", "<leader>xl", ":clast<CR>zz", { desc = "Quickfix: Last item" })
|
|
|
|
--- Location list navigation — next, previous, open, close.
|
|
keymap.set("n", "<leader>ln", ":lnext<CR>zz", { desc = "Location: Next item" })
|
|
keymap.set("n", "<leader>lp", ":lprev<CR>zz", { desc = "Location: Previous item" })
|
|
keymap.set("n", "<leader>lo", ":lopen<CR>", { desc = "Location: Open list" })
|
|
keymap.set("n", "<leader>lq", ":lclose<CR>", { desc = "Location: Close list" })
|