| @ -0,0 +1,93 @@ | |||||
| return { | |||||
| "mfussenegger/nvim-dap", | |||||
| dependencies = { | |||||
| "rcarriga/nvim-dap-ui", | |||||
| "theHamsta/nvim-dap-virtual-text", | |||||
| }, | |||||
| config = function() | |||||
| local dap = require("dap") | |||||
| local dapui = require('dapui') | |||||
| -- Setup DAP UI with explicit configuration | |||||
| dapui.setup() | |||||
| dap.adapters.php = { | |||||
| type = 'executable', | |||||
| command = vim.fn.stdpath('data') .. '/mason/bin/php-debug-adapter', | |||||
| } | |||||
| -- Get the correct project paths (make this global so keys can access it) | |||||
| _G.get_project_paths = function() | |||||
| local cwd = vim.fn.getcwd() | |||||
| -- Check if we're in the project root (where docker-compose.yml is) | |||||
| if vim.fn.filereadable(cwd .. "/docker-compose.yml") == 1 then | |||||
| return { | |||||
| project_root = cwd, | |||||
| api_path = cwd .. "/app/api", | |||||
| docker_path = "/var/www" | |||||
| } | |||||
| -- Check if we're in the app/api directory | |||||
| elseif string.match(cwd, "app/api$") then | |||||
| local project_root = string.gsub(cwd, "/app/api$", "") | |||||
| return { | |||||
| project_root = project_root, | |||||
| api_path = cwd, | |||||
| docker_path = "/var/www" | |||||
| } | |||||
| else | |||||
| -- Fallback - assume we're somewhere in the project | |||||
| return { | |||||
| project_root = cwd, | |||||
| api_path = cwd, | |||||
| docker_path = "/var/www" | |||||
| } | |||||
| end | |||||
| end | |||||
| local paths = _G.get_project_paths() | |||||
| -- PHP configurations | |||||
| dap.configurations.php = { | |||||
| { | |||||
| name = "🚀 Jack Laravel - Listen for Xdebug", | |||||
| type = "php", | |||||
| request = "launch", | |||||
| port = 9003, | |||||
| pathMappings = { | |||||
| [paths.docker_path] = paths.api_path, | |||||
| }, | |||||
| hostname = "0.0.0.0", | |||||
| log = true, | |||||
| xdebugSettings = { | |||||
| max_children = 512, | |||||
| max_data = 1024, | |||||
| max_depth = 4, | |||||
| }, | |||||
| }, | |||||
| { | |||||
| name = "🌐 Jack Laravel - Web Request Debug", | |||||
| type = "php", | |||||
| request = "launch", | |||||
| port = 9003, | |||||
| pathMappings = { | |||||
| ["/var/www"] = paths.api_path, | |||||
| }, | |||||
| hostname = "0.0.0.0", | |||||
| -- Pre-configure for Laravel routes | |||||
| breakMode = "request", | |||||
| } | |||||
| } | |||||
| end, | |||||
| keys = { | |||||
| { "<leader>DD", function() require("dap").continue() end, desc = "Start Laravel Debug" }, | |||||
| { "<leader>Ds", function() require("dap").step_over() end, desc = "Step Over" }, | |||||
| { "<leader>Di", function() require("dap").step_into() end, desc = "Step Into" }, | |||||
| { "<leader>Do", function() require("dap").step_out() end, desc = "Step Out" }, -- Fixed: was "Ds" twice | |||||
| { "<leader>bp", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" }, | |||||
| { "<leader>bP", function() require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: ")) end, desc = "Conditional Breakpoint" }, | |||||
| { "<leader>dr", function() require("dap").repl.open() end, desc = "Open REPL" }, | |||||
| { "<leader>dl", function() require("dap").run_last() end, desc = "Run Last" }, | |||||
| { "<leader>du", function() require("dapui").toggle() end, desc = "Toggle DAP UI" }, | |||||
| }, | |||||
| } | |||||