mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.1k stars 179 forks source link

No reaction to configurations change in Godot 4 #1188

Closed lunaro-4 closed 2 months ago

lunaro-4 commented 3 months ago

Debug adapter definition and debug configuration

Installed via packer, configured as in example. Originally wanted to launch specific debug scene (instead of default 'main'), but it turns out, only required fields ( 'type', 'request' and 'name' ) and 'project' field have effect on engine's behavior.

Changing 'project' field can return error in godot, if path does not contain project.godot, or contain project.godot form project, other than currently oppened


local dap = require("dap")
dap.adapters.godot = {
    type = "server",
    host = "127.0.0.1",
    port = 6006,
}

dap.configurations.gdscript = {
  {
      name = "Launch scene",
      -- request = "connect",
      request = "launch",
      type = "godot",
      project = "${workspaceFolder}", -- has effect
      scene = "current", -- no effect
      launch_scene = false, -- no effect
  }
}

Debug adapter version

0.7.0

Steps to Reproduce

  1. Launch any Godot project (my version is v4.2.1.stable.official [b09f793f5])
  2. Open script, connected to scene in neovim
  3. run :lua require('dap').continue()

Expected Result

Launch current scene, or do not launch at all (since launch_scene = false)

Actual Result

Main scene launches

lunaro-4 commented 3 months ago

Here is the log from last launch

[ DEBUG ] 2024-04-05T21:40:03Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1306 ] "Connecting to debug adapter" { host = "127.0.0.1", port = 6006, type = "server" } [ DEBUG ] 2024-04-05T21:40:03Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1683 ] "request" { arguments = { adapterID = "nvim-dap", clientID = "neovim", clientName = "neovim", columnsStartAt1 = true, linesStartAt1 = true, locale = "en_US.UTF-8", pathFormat = "path", supportsProgressReporting = true, supportsRunInTerminalRequest = true, supportsStartDebuggingRequest = true, supportsVariableType = true }, command = "initialize", seq = 1, type = "request" } [ DEBUG ] 2024-04-05T21:40:03Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 1 { body = { supportSuspendDebuggee = true, supportTerminateDebuggee = true, supportedChecksumAlgorithms = { "MD5", "SHA256" }, supportsBreakpointLocationsRequest = true, supportsConfigurationDoneRequest = true, supportsEvaluateForHovers = true, supportsRestartRequest = true, supportsSetVariable = true, supportsTerminateRequest = true, supportsValueFormattingOptions = true }, command = "initialize", request_seq = 1, seq = 1, success = true, type = "response" } [ DEBUG ] 2024-04-05T21:40:03Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1683 ] "request" { arguments = { launch_scene = false, name = "Launch scene", project = "/home/lunaro/GodotProjects/my-game", request = "launch", scene = "current", type = "godot" }, command = "launch", seq = 2, type = "request" } [ DEBUG ] 2024-04-05T21:40:03Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 1 { event = "initialized", seq = 2, type = "event" } [ DEBUG ] 2024-04-05T21:40:03Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1683 ] "request" { command = "configurationDone", seq = 3, type = "request" } [ DEBUG ] 2024-04-05T21:40:04Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 1 { command = "launch", request_seq = 2, seq = 3, success = true, type = "response" } [ DEBUG ] 2024-04-05T21:40:04Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 1 { body = { name = "/usr/bin/Godot", startMethod = "launch" }, event = "process", seq = 4, type = "event" } [ DEBUG ] 2024-04-05T21:40:04Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 1 { command = "configurationDone", request_seq = 3, seq = 5, success = true, type = "response" } [ DEBUG ] 2024-04-05T21:40:10Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 1 { body = { category = "stdout", output = "Godot Engine v4.2.1.stable.official.b09f793f5 - https://godotengine.org\nVulkan API 1.3.255 - Forward+ - Using Vulkan Device #0: AMD - AMD Radeon RX 6600 (RADV NAVI23)\n \r\n" }, event = "output", seq = 6, type = "event" } [ DEBUG ] 2024-04-05T21:40:13Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 1 { body = { exitCode = 0 }, event = "exited", seq = 7, type = "event" } [ DEBUG ] 2024-04-05T21:40:13Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 1 { event = "terminated", seq = 8, type = "event" }
lunaro-4 commented 3 months ago

I have also tried launching server form godot and changing request to 'connect', and than dap either says Debug adapter didn't respond. Either the adapter is slow (then wait and ignore this) or there is a problem with your adapter or `godot` config uration. Check the logs for errors (:help dap.set_log_level) or gives 3 errors:

Error executing vim.schedule lua callback: ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:956: Expected comma or object end but f
ound invalid token at character 107
stack traceback:
        [C]: in function 'json_decode'
        ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:956: in function 'handle_body'
        ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1343: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Error executing luv callback:
...are/nvim/site/pack/packer/start/nvim-dap/lua/dap/rpc.lua:81: ...are/nvim/site/pack/packer/start/nvim-dap/lua/dap/rpc.lua:36: bad argument #
1 to 'sub' (number expected, got nil)
stack traceback:
        [C]: in function 'parse_chunk'
        ...are/nvim/site/pack/packer/start/nvim-dap/lua/dap/rpc.lua:81: in function <...are/nvim/site/pack/packer/start/nvim-dap/lua/dap/rpc.l
ua:67>

Error executing luv callback:
...are/nvim/site/pack/packer/start/nvim-dap/lua/dap/rpc.lua:81: cannot resume dead coroutine
stack traceback:
        [C]: in function 'parse_chunk'
        ...are/nvim/site/pack/packer/start/nvim-dap/lua/dap/rpc.lua:81: in function <...are/nvim/site/pack/packer/start/nvim-dap/lua/dap/rpc.l
ua:67>

and log is :

[ INFO ] 2024-04-05T21:48:36Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1795 ] "Session closed due to disconnect" [ DEBUG ] 2024-04-05T21:48:38Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1306 ] "Connecting to debug adapter" { host = "127.0.0.1", port = 6006, type = "server" } [ DEBUG ] 2024-04-05T21:48:38Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1683 ] "request" { arguments = { adapterID = "nvim-dap", clientID = "neovim", clientName = "neovim", columnsStartAt1 = true, linesStartAt1 = true, locale = "en_US.UTF-8", pathFormat = "path", supportsProgressReporting = true, supportsRunInTerminalRequest = true, supportsStartDebuggingRequest = true, supportsVariableType = true }, command = "initialize", seq = 1, type = "request" } [ DEBUG ] 2024-04-05T21:48:38Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 2 { body = { supportSuspendDebuggee = true, supportTerminateDebuggee = true, supportedChecksumAlgorithms = { "MD5", "SHA256" }, supportsBreakpointLocationsRequest = true, supportsConfigurationDoneRequest = true, supportsEvaluateForHovers = true, supportsRestartRequest = true, supportsSetVariable = true, supportsTerminateRequest = true, supportsValueFormattingOptions = true }, command = "initialize", request_seq = 1, seq = 1, success = true, type = "response" } [ DEBUG ] 2024-04-05T21:48:38Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1683 ] "request" { arguments = { launch_scene = false, name = "Launch scene", project = "/home/lunaro/GodotProjects/my-rebirth-into-a-game", request = "connect", scene = "current", type = "godot" }, command = "connect", seq = 2, type = "request" } [ DEBUG ] 2024-04-05T21:48:38Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 2 { event = "initialized", seq = 2, type = "event" } [ DEBUG ] 2024-04-05T21:48:38Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1683 ] "request" { command = "configurationDone", seq = 3, type = "request" } [ DEBUG ] 2024-04-05T21:48:38Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:957 ] 2 { command = "configurationDone", request_seq = 3, seq = 3, success = true, type = "response" }
mfussenegger commented 2 months ago

According to https://github.com/godotengine/godot-vscode-plugin?tab=readme-ov-file#configurations there is no launch_scene

I'm not sure why the scene property is not taking any effect. According to the log it's sent correctly:

[ DEBUG ] 2024-04-05T21:40:03Z+0300 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1683 ] "request" {
arguments = {
launch_scene = false,
name = "Launch scene",
project = "/home/lunaro/GodotProjects/my-game",
request = "launch",
scene = "current",
type = "godot"
},

It not getting used would be a problem in the godot/dap implementation. The client does what it's supposed to do.

lunaro-4 commented 2 months ago

Yes, after further inspection, I found a lot of complains about dap in godot engine, like this one, so it is definitely related to godot itself. Thank you for responding!