From 1f747a12ea38153845d8dde1f579aa0f806db804 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Date: Tue, 13 Jan 2026 22:07:26 -0500 Subject: [PATCH] fixing configuration to change the windows --- CHANGELOG.md | 29 +++- README.md | 71 +++++++++- ftplugin/java.lua | 6 +- lua/cargdev/core/keymaps/README.md | 21 ++- lua/cargdev/core/keymaps/gitconflict.lua | 10 +- lua/cargdev/core/keymaps/personal.lua | 1 - lua/cargdev/plugins/dap.lua | 168 +++++++++++++++++++---- lua/cargdev/plugins/lsp/mason.lua | 2 + 8 files changed, 268 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6619e5e..5a40621 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Added +- **Python Debugger (debugpy)**: Full Python debugging support with multiple configurations + - Launch File - Debug current Python file + - Launch with Arguments - Debug with custom arguments + - Attach Remote - Attach to debugpy server (port 5678) + - Django - Debug Django with `manage.py runserver` + - FastAPI - Debug FastAPI with uvicorn + - Flask - Debug Flask application +- **Node.js/NestJS Debug Configurations**: Extended TypeScript/JavaScript debugging + - Launch NestJS (`dist/main.js`) with source maps + - Launch Current File + - Launch with ts-node (debug TypeScript directly) + - Attach to NestJS (port 9229) + - Attach to Process (pick from running processes) +- **Mason Debug Adapters**: Added `debugpy` and `js-debug-adapter` to auto-install list +- **README Documentation**: Added comprehensive "Debugging Setup" section with all configurations - **Avante.nvim AI Assistant**: Added Avante.nvim with local LLM support to README documentation - **Bash Treesitter Parser**: Installed bash parser for noice.nvim cmdline highlighting - **Local Configuration Support**: `local.lua` is now loaded at startup and exposed via `vim.g.cargdev_local` @@ -30,6 +45,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `lazygit.lua` - removed commented hardcoded path ### Fixed +- **Java Debug Adapter Paths**: Fixed incorrect paths in `ftplugin/java.lua` + - Changed `java-debug` → `java-debug-adapter/extension/server/` + - Changed `vscode-java-test` → `java-test/extension/server/` +- **Node.js DAP Adapter**: Fixed js-debug-adapter configuration in `dap.lua` + - Changed adapter type from `executable` to `server` (required by js-debug-adapter) + - Renamed adapter from `node` to `pwa-node` (standard DAP name) + - Added proper source map resolution and skipFiles patterns - **Auto-session Lazy Loading**: Changed from `event = "VeryLazy"` to `lazy = false` to enable session auto-restore on startup - **Alpha Dashboard Config**: Fixed `enable` to `enabled` (correct lazy.nvim spec key) - **Snacks vs Alpha Conflict**: Disabled `Snacks.dashboard` in favor of `alpha-nvim` for CARGDEV branding @@ -163,6 +185,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Modified Files | File | Changes | |------|---------| +| `lua/cargdev/plugins/dap.lua` | Fixed Node.js adapter, added Python debugpy config | +| `ftplugin/java.lua` | Fixed java-debug-adapter and java-test paths | +| `lua/cargdev/plugins/lsp/mason.lua` | Added debugpy and js-debug-adapter to ensure_installed | +| `README.md` | Added Debugging Setup section with keymaps and configurations | +| `lua/cargdev/core/keymaps/README.md` | Added dap.lua and other keymap files to structure | | `lua/cargdev/core/keymaps/personal.lua` | Removed duplicates, added quickfix/location keymaps, safe buffer close | | `lua/cargdev/core/keymaps/plugins.lua` | Fixed session/substitute keymap conflicts | | `lua/cargdev/core/keymaps/general.lua` | Added vault_path validation, removed commented code | @@ -216,4 +243,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). --- -*Last Updated: January 10, 2026* +*Last Updated: January 13, 2026* diff --git a/README.md b/README.md index e15fda0..a969fab 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ nvim - **File Explorer**: nvim-tree - **Git Integration**: LazyGit, Gitsigns - **AI Assistants**: GitHub Copilot + [Avante.nvim](https://github.com/yetone/avante.nvim) (local LLM support) -- **Debugging**: DAP with UI +- **Debugging**: DAP with UI (Java, Node.js/NestJS, Python) - **Formatting**: Conform.nvim with auto-format on save - **Diagnostics**: Trouble.nvim for organized diagnostics view @@ -149,6 +149,33 @@ nvim | `ze` | Explain code (visual) | | `zf` | Fix code (visual) | +### Debugging (DAP) +| Keymap | Description | +|--------|-------------| +| `dcr` | Start/Continue Debugging | +| `db` | Toggle Breakpoint | +| `dB` | Conditional Breakpoint | +| `do` | Step Over | +| `di` | Step Into | +| `dot` | Step Out | +| `du` | Toggle DAP UI | +| `dq` | Stop Debugging | +| `dr` | Open REPL | +| `dl` | Run Last Debug | +| `dcf` | DAP Configurations | +| `dcb` | List Breakpoints | +| `dco` | DAP Commands | + +### Java Debugging +| Keymap | Description | +|--------|-------------| +| `jd` | Debug Class (DAP) | +| `jt` | Test Class | +| `jn` | Test Nearest Method | +| `jr` | Run Java File | +| `jm` | Run Maven Project | +| `jg` | Run Gradle Project | + ## Commands | Command | Description | @@ -159,6 +186,48 @@ nvim | `:CheckConfig` | Run config validation | | `:FormatToggle` | Toggle auto-format on save | +## Debugging Setup + +This configuration includes full debugging support for multiple languages using DAP (Debug Adapter Protocol). + +### Supported Languages + +| Language | Debug Adapter | Configuration | +|----------|---------------|---------------| +| **Java** | java-debug-adapter | Auto-configured via nvim-jdtls | +| **Node.js/NestJS/TypeScript** | js-debug-adapter (pwa-node) | Launch & Attach configurations | +| **Python** | debugpy | Django, FastAPI, Flask, and general Python | + +### Debug Configurations + +#### Node.js/NestJS/TypeScript +- **Launch NestJS** - Runs `dist/main.js` with source maps +- **Launch Current File** - Debug the current TypeScript/JavaScript file +- **Launch with ts-node** - Debug TypeScript directly without compilation +- **Attach to NestJS** - Attach to running process on port 9229 +- **Attach to Process** - Pick from running Node.js processes + +#### Python +- **Launch File** - Debug current Python file +- **Launch with Arguments** - Debug with custom arguments +- **Attach Remote** - Attach to debugpy server (port 5678) +- **Django** - Debug Django with `manage.py runserver` +- **FastAPI** - Debug FastAPI with uvicorn +- **Flask** - Debug Flask application + +#### Java +- Auto-discovers main classes and test methods +- Hot code replacement enabled +- Use `jd` to debug the current class + +### Installation + +Debug adapters are automatically installed via Mason. Run `:Mason` to verify: +- `debugpy` - Python debugger +- `js-debug-adapter` - Node.js/TypeScript debugger +- `java-debug-adapter` - Java debugger +- `java-test` - Java test runner + ## Troubleshooting ### Check Configuration Health diff --git a/ftplugin/java.lua b/ftplugin/java.lua index 346e395..b328c29 100644 --- a/ftplugin/java.lua +++ b/ftplugin/java.lua @@ -13,13 +13,13 @@ local extendedClientCapabilities = jdtls.extendedClientCapabilities local bundles = { vim.fn.glob( - home - .. "/.local/share/nvim/mason/packages/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar" + home .. "/.local/share/nvim/mason/packages/java-debug-adapter/extension/server/com.microsoft.java.debug.plugin-*.jar", + true ), } vim.list_extend( bundles, - vim.split(vim.fn.glob(home .. "/.local/share/nvim/mason/packages/vscode-java-test/server/*.jar", true), "\n") + vim.split(vim.fn.glob(home .. "/.local/share/nvim/mason/packages/java-test/extension/server/*.jar", true), "\n") ) local config = { diff --git a/lua/cargdev/core/keymaps/README.md b/lua/cargdev/core/keymaps/README.md index 8577969..682a65a 100644 --- a/lua/cargdev/core/keymaps/README.md +++ b/lua/cargdev/core/keymaps/README.md @@ -9,9 +9,13 @@ keymaps/ ├── README.md # This file ├── general.lua # General keymaps (leader, basic navigation) ├── personal.lua # Personal workflow keymaps -├── lsp.lua # LSP and function navigation keymaps -├── snacks.lua # Snacks search and navigation keymaps (replacing Telescope) -└── plugins.lua # Plugin-specific keymaps +├── lsp.lua # LSP and function navigation keymaps +├── dap.lua # DAP debugging keymaps +├── snacks.lua # Snacks search and navigation keymaps (replacing Telescope) +├── window.lua # Window management keymaps +├── copilot.lua # Copilot AI keymaps +├── gitconflict.lua # Git conflict resolution keymaps +└── plugins.lua # Plugin-specific keymaps ``` ## 🔧 How It Works @@ -36,6 +40,13 @@ The main `keymaps.lua` file automatically loads all `.lua` files from this folde - Code actions and documentation - Diagnostics +### **dap.lua** +- Debug session control (`dcr`, `dq`) +- Breakpoints (`db`, `dB`) +- Step navigation (`do`, `di`, `dot`) +- DAP UI toggle (`du`) +- REPL and configuration pickers + ### **snacks.lua** - File search (`ff`, `fs`) - Buffer management @@ -71,7 +82,11 @@ To add new keymaps: | General | `general.lua` | Basic setup and utilities | | Personal | `personal.lua` | Your workflow shortcuts | | LSP | `lsp.lua` | Function navigation and LSP features | +| Debugging | `dap.lua` | DAP debugging (Java, Node.js, Python) | | Search | `snacks.lua` | File and text search | +| Window | `window.lua` | Window/split management | +| Copilot | `copilot.lua` | AI assistant keymaps | +| Git Conflicts | `gitconflict.lua` | Conflict resolution | | Plugins | `plugins.lua` | Plugin-specific functionality | ## 🔄 Benefits diff --git a/lua/cargdev/core/keymaps/gitconflict.lua b/lua/cargdev/core/keymaps/gitconflict.lua index dcbe216..f242a5e 100644 --- a/lua/cargdev/core/keymaps/gitconflict.lua +++ b/lua/cargdev/core/keymaps/gitconflict.lua @@ -3,8 +3,8 @@ local keymap = vim.keymap keymap.set("n", "]x", "(git-conflict-next-conflict)", { desc = "Go to next git conflict" }) keymap.set("n", "[x", "(git-conflict-prev-conflict)", { desc = "Go to previous git conflict" }) -keymap.set("n", "co", "(git-conflict-ours)", { desc = "Choose ours (git conflict)" }) -keymap.set("n", "ct", "(git-conflict-theirs)", { desc = "Choose theirs (git conflict)" }) -keymap.set("n", "cb", "(git-conflict-both)", { desc = "Choose both (git conflict)" }) -keymap.set("n", "c0", "(git-conflict-none)", { desc = "Choose none (git conflict)" }) -keymap.set("n", "cq", "(git-conflict-list)", { desc = "List all git conflicts" }) +keymap.set("n", "gco", "(git-conflict-ours)", { desc = "Choose ours (git conflict)" }) +keymap.set("n", "gct", "(git-conflict-theirs)", { desc = "Choose theirs (git conflict)" }) +keymap.set("n", "gcb", "(git-conflict-both)", { desc = "Choose both (git conflict)" }) +keymap.set("n", "gc0", "(git-conflict-none)", { desc = "Choose none (git conflict)" }) +keymap.set("n", "gcl", "(git-conflict-list)", { desc = "List all git conflicts" }) diff --git a/lua/cargdev/core/keymaps/personal.lua b/lua/cargdev/core/keymaps/personal.lua index 0e2814c..83eaebf 100644 --- a/lua/cargdev/core/keymaps/personal.lua +++ b/lua/cargdev/core/keymaps/personal.lua @@ -67,7 +67,6 @@ keymap.set( ) keymap.set("n", ",", "$a,", { desc = "Adding ',' at the end of the line" }) keymap.set("n", ";", "$a;", { desc = "Adding ';' at the end of the line" }) -keymap.set("n", "con", "oconsole.log()0w$h", { desc = "Adding console.log() on the line below" }) keymap.set("n", "xr", ":!node %", { desc = "Run file with node" }) -- Resize splits keymaps are centralized in lua/cargdev/core/keymaps/window.lua diff --git a/lua/cargdev/plugins/dap.lua b/lua/cargdev/plugins/dap.lua index 91da8b0..3fe3b3b 100644 --- a/lua/cargdev/plugins/dap.lua +++ b/lua/cargdev/plugins/dap.lua @@ -77,8 +77,9 @@ return { -- 🧠 Mason DAP require("mason-nvim-dap").setup({ - ensure_installed = { "js-debug-adapter", "firefox", "javadbg", "javatest" }, - automatic_setup = true, + ensure_installed = { "python", "js", "javadbg", "javatest" }, + automatic_installation = true, + handlers = {}, }) -- 🔍 Virtual Text @@ -144,45 +145,160 @@ return { -- via jdtls.setup_dap() which automatically sets up the adapter -- The configurations are dynamically discovered from the project - -- 🧠 Node.js (NestJS / TypeScript) - Using js-debug-adapter - dap.adapters.node = { - type = "executable", - command = "node", - args = { - os.getenv("HOME") .. "/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js", - "${port}", + -- 🐍 Python (debugpy) + local debugpy_path = os.getenv("HOME") .. "/.local/share/nvim/mason/packages/debugpy/venv/bin/python" + require("dap-python").setup(debugpy_path) + + dap.configurations.python = { + { + name = "Launch File", + type = "python", + request = "launch", + program = "${file}", + console = "integratedTerminal", + cwd = fn.getcwd(), + }, + { + name = "Launch File with Arguments", + type = "python", + request = "launch", + program = "${file}", + args = function() + local args_string = vim.fn.input("Arguments: ") + return vim.split(args_string, " +") + end, + console = "integratedTerminal", + cwd = fn.getcwd(), + }, + { + name = "Attach Remote", + type = "python", + request = "attach", + connect = { + host = "127.0.0.1", + port = 5678, + }, + }, + { + name = "Django", + type = "python", + request = "launch", + program = "${workspaceFolder}/manage.py", + args = { "runserver", "--noreload" }, + console = "integratedTerminal", + django = true, + }, + { + name = "FastAPI", + type = "python", + request = "launch", + module = "uvicorn", + args = { "main:app", "--reload" }, + console = "integratedTerminal", + cwd = fn.getcwd(), + }, + { + name = "Flask", + type = "python", + request = "launch", + module = "flask", + env = { FLASK_APP = "app.py", FLASK_DEBUG = "1" }, + args = { "run", "--no-debugger", "--no-reload" }, + console = "integratedTerminal", + }, + } + + -- 🧠 Node.js (NestJS / TypeScript) - Using js-debug-adapter (pwa-node) + dap.adapters["pwa-node"] = { + type = "server", + host = "localhost", + port = "${port}", + executable = { + command = "node", + args = { + os.getenv("HOME") .. "/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js", + "${port}", + }, }, } dap.configurations.typescript = { { - name = "Launch NestJS", - type = "node", + name = "Launch NestJS (dist/main.js)", + type = "pwa-node", request = "launch", program = "${workspaceFolder}/dist/main.js", - args = {}, - console = "integratedTerminal", - outFiles = { "${workspaceFolder}/dist/**/*.js" }, + cwd = "${workspaceFolder}", sourceMaps = true, - protocol = "inspector", - cwd = fn.getcwd(), - runtimeArgs = { "--inspect-brk" }, + outFiles = { "${workspaceFolder}/dist/**/*.js" }, + resolveSourceMapLocations = { "${workspaceFolder}/**", "!**/node_modules/**" }, + console = "integratedTerminal", + skipFiles = { "/**", "node_modules/**" }, + }, + { + name = "Launch Current File", + type = "pwa-node", + request = "launch", + program = "${file}", + cwd = "${workspaceFolder}", + sourceMaps = true, + console = "integratedTerminal", + skipFiles = { "/**", "node_modules/**" }, + }, + { + name = "Launch with ts-node", + type = "pwa-node", + request = "launch", + runtimeExecutable = "node", + runtimeArgs = { "--loader", "ts-node/esm" }, + program = "${file}", + cwd = "${workspaceFolder}", + sourceMaps = true, + console = "integratedTerminal", + skipFiles = { "/**", "node_modules/**" }, + }, + { + name = "Attach to NestJS (port 9229)", + type = "pwa-node", + request = "attach", + port = 9229, + cwd = "${workspaceFolder}", + sourceMaps = true, + outFiles = { "${workspaceFolder}/dist/**/*.js" }, + resolveSourceMapLocations = { "${workspaceFolder}/**", "!**/node_modules/**" }, + skipFiles = { "/**", "node_modules/**" }, restart = true, }, { - name = "Attach to NestJS (start:debug)", - type = "node", + name = "Attach to Process", + type = "pwa-node", request = "attach", - port = 9229, - protocol = "inspector", - cwd = fn.getcwd(), + processId = require("dap.utils").pick_process, + cwd = "${workspaceFolder}", sourceMaps = true, - outFiles = { "${workspaceFolder}/dist/**/*.js" }, - skipFiles = { "/**" }, + skipFiles = { "/**", "node_modules/**" }, }, } - -- Also add JavaScript configurations - dap.configurations.javascript = dap.configurations.typescript + -- JavaScript uses same configurations as TypeScript + dap.configurations.javascript = { + { + name = "Launch Current File", + type = "pwa-node", + request = "launch", + program = "${file}", + cwd = "${workspaceFolder}", + console = "integratedTerminal", + skipFiles = { "/**", "node_modules/**" }, + }, + { + name = "Attach to Process", + type = "pwa-node", + request = "attach", + processId = require("dap.utils").pick_process, + cwd = "${workspaceFolder}", + skipFiles = { "/**", "node_modules/**" }, + }, + } end, } diff --git a/lua/cargdev/plugins/lsp/mason.lua b/lua/cargdev/plugins/lsp/mason.lua index 30f896e..1c85a77 100644 --- a/lua/cargdev/plugins/lsp/mason.lua +++ b/lua/cargdev/plugins/lsp/mason.lua @@ -54,6 +54,8 @@ return { "tree-sitter-cli", -- required for nvim-treesitter parser compilation "java-debug-adapter", -- Java debugger "java-test", -- Java test runner + "debugpy", -- Python debugger + "js-debug-adapter", -- Node.js/TypeScript debugger }, }) end,