diff --git a/lazy-lock.json b/lazy-lock.json index 809a28c2..0ce93f8b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -17,7 +17,10 @@ "mini.nvim": { "branch": "main", "commit": "ee4a4a4abed25e3d108d985b0553c5271f2f71aa" }, "neo-tree.nvim": { "branch": "main", "commit": "8cdd6b1940f333c1dd085526a9c45b30fb2dbf50" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-dap": { "branch": "master", "commit": "6782b097af2417a4c3e33849b0a26ae2188bd7ea" }, + "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, "nvim-lspconfig": { "branch": "master", "commit": "87d30189b24caa496b54affd65594a309ac6d929" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, diff --git a/lua/custom/plugins/flutter.lua b/lua/custom/plugins/flutter.lua index 3c89917b..b817d4ab 100644 --- a/lua/custom/plugins/flutter.lua +++ b/lua/custom/plugins/flutter.lua @@ -16,6 +16,19 @@ -- ======================================================================== return { + -- ======================================================================== + -- NVIM-DAP - Debug Adapter Protocol for Flutter debugging + -- ======================================================================== + -- Load DAP when opening Dart files to enable breakpoint debugging + { + 'mfussenegger/nvim-dap', + ft = 'dart', + dependencies = { + 'rcarriga/nvim-dap-ui', + 'nvim-neotest/nvim-nio', + }, + }, + -- ======================================================================== -- FLUTTER TOOLS - Complete Flutter development environment -- ======================================================================== @@ -30,6 +43,16 @@ return { -- fe - Flutter Emulators (launch emulator) -- fo - Flutter Outline (toggle outline/widget tree) -- fc - Flutter Copy Profile URL (for DevTools) + -- + -- Debug keymaps: + -- - Start/Continue debugging + -- - Step over + -- - Step into + -- - Step out + -- db - Toggle breakpoint + -- dB - Set conditional breakpoint + -- dc - Continue + -- dt - Terminate debugging -- ======================================================================== { 'nvim-flutter/flutter-tools.nvim', @@ -37,6 +60,9 @@ return { dependencies = { 'nvim-lua/plenary.nvim', 'stevearc/dressing.nvim', -- Optional: better UI for Flutter commands + 'mfussenegger/nvim-dap', + 'rcarriga/nvim-dap-ui', + 'nvim-neotest/nvim-nio', }, config = function() -- Get shared LSP capabilities from blink.cmp @@ -87,10 +113,40 @@ return { debugger = { enabled = true, -- Enable Flutter debugger integration - run_via_dap = false, -- Use Flutter tools debugger (not DAP) + run_via_dap = true, -- Use DAP for debugging + -- Flutter tools will automatically register DAP configurations + -- No need to manually configure launch.json }, } + -- ======================================================================== + -- DAP UI SETUP - Beautiful debugging interface + -- ======================================================================== + local dap, dapui = require 'dap', require 'dapui' + + -- Configure DAP UI + dapui.setup { + icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, + controls = { + icons = { + pause = '⏸', + play = '▶', + step_into = '⏎', + step_over = '⏭', + step_out = '⏮', + step_back = 'b', + run_last = '▶▶', + terminate = '⏹', + disconnect = '⏏', + }, + }, + } + + -- Automatically open/close DAP UI + dap.listeners.after.event_initialized['dapui_config'] = dapui.open + dap.listeners.before.event_terminated['dapui_config'] = dapui.close + dap.listeners.before.event_exited['dapui_config'] = dapui.close + -- ======================================================================== -- FLUTTER-SPECIFIC KEYMAPS -- ======================================================================== @@ -121,9 +177,51 @@ return { ) vim.keymap.set('n', 'fl', 'FlutterLspRestart', vim.tbl_extend('force', opts, { desc = '[F]lutter [L]SP Restart' })) - -- Register Flutter group with which-key + -- ======================================================================== + -- DEBUG KEYMAPS - Available only in Dart files + -- ======================================================================== + -- Function key shortcuts (standard debugging) + vim.keymap.set('n', '', function() + require('dap').continue() + end, vim.tbl_extend('force', opts, { desc = 'Debug: Start/Continue' })) + + vim.keymap.set('n', '', function() + require('dap').step_over() + end, vim.tbl_extend('force', opts, { desc = 'Debug: Step Over' })) + + vim.keymap.set('n', '', function() + require('dap').step_into() + end, vim.tbl_extend('force', opts, { desc = 'Debug: Step Into' })) + + vim.keymap.set('n', '', function() + require('dap').step_out() + end, vim.tbl_extend('force', opts, { desc = 'Debug: Step Out' })) + + -- Leader-based debug commands + vim.keymap.set('n', 'db', function() + require('dap').toggle_breakpoint() + end, vim.tbl_extend('force', opts, { desc = '[D]ebug: Toggle [B]reakpoint' })) + + vim.keymap.set('n', 'dB', function() + require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, vim.tbl_extend('force', opts, { desc = '[D]ebug: Set Conditional [B]reakpoint' })) + + vim.keymap.set('n', 'dc', function() + require('dap').continue() + end, vim.tbl_extend('force', opts, { desc = '[D]ebug: [C]ontinue' })) + + vim.keymap.set('n', 'dt', function() + require('dap').terminate() + end, vim.tbl_extend('force', opts, { desc = '[D]ebug: [T]erminate' })) + + vim.keymap.set('n', 'du', function() + require('dapui').toggle() + end, vim.tbl_extend('force', opts, { desc = '[D]ebug: Toggle [U]I' })) + + -- Register groups with which-key require('which-key').add { { 'f', group = '[F]lutter', mode = 'n' }, + { 'd', group = '[D]ebug', mode = 'n' }, } end, })