Skip to content

Commit

Permalink
fix(dap): attach debugger on windows (#381)
Browse files Browse the repository at this point in the history
* fix: do not register configurations twice

Configurations are registered in debug runner run method

* fix: gracefully handle missing configurations

* fix: attach debugger on windows

Config changed according documentation in https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#dart, fixes #274
  • Loading branch information
sidlatau authored Aug 29, 2024
1 parent e6671ce commit d8f2eac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lua/flutter-tools/dap.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
local ui = require("flutter-tools.ui")
local lazy = require("flutter-tools.lazy")
local path = lazy.require("flutter-tools.utils.path") ---@module "flutter-tools.utils.path"
local ui = lazy.require("flutter-tools.ui") ---@module "flutter-tools.ui"

local success, dap = pcall(require, "dap")
if not success then
Expand Down Expand Up @@ -29,7 +31,13 @@ function M.setup(config)
command = paths.flutter_bin,
args = { "debug-adapter" },
}
opts.register_configurations(paths)
if path.is_windows then
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#dart
-- add this if on windows, otherwise server won't open successfully
dap.adapters.dart.options = {
detached = false,
}
end
local repl = require("dap.repl")
repl.commands = vim.tbl_extend("force", repl.commands, {
custom_commands = {
Expand Down
4 changes: 4 additions & 0 deletions lua/flutter-tools/runners/debugger_runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ function DebuggerRunner:run(paths, args, cwd, on_run_data, on_run_exit)
local launch_configuration_count = 0
config.debugger.register_configurations(paths)
local all_configurations = require("dap").configurations.dart
if not all_configurations then
ui.notify("No launch configuration for DAP found", ui.ERROR)
return
end
for _, c in ipairs(all_configurations) do
if c.request == "launch" then
table.insert(launch_configurations, c)
Expand Down

0 comments on commit d8f2eac

Please sign in to comment.