Skip to content

DAP support python

Zeioth edited this page Aug 8, 2023 · 9 revisions

Nothing special needs to be done for python.

How to configure DAP for python

Please note that this section has nothing to do with compiler.nvim. I'm documenting this to make your life easier. To debug python with DAP you have to:

  • Install pydebug using Mason, or manually with: :MasonInstall debugpy@1.6.7.
  • Then add the python adapter and configuration to the dap plugin config like
local dap = require("dap")

-- Python
dap.adapters.python = {
  type = 'executable',
  command = vim.fn.stdpath('data')..'/mason/packages/debugpy/venv/bin/python',
  args = { '-m', 'debugpy.adapter' },
}
dap.configurations.python = {
  {
    type = "python",
    request = "launch",
    name = "Launch file",
    program = "${file}",
  },
}

All there is left to do is adding a breakpoint to your code, and run :DapContinue screenshot_2023-08-07_20-43-39_375625350

Important for you to know

  • Note that mason installs the debugger for you. You don't need to install any system dependency.
  • If you find any issue while configuring DAP, run :DapSetLogLevel trace and :DapShowLog to find the reason.