diff options
| author | Vito G. Graffagnino <vito@graffagnino.xyz> | 2022-07-22 16:42:35 +0100 |
|---|---|---|
| committer | Vito G. Graffagnino <vito@graffagnino.xyz> | 2022-07-22 16:42:35 +0100 |
| commit | fa9ba544bc8c8f4398cd2138841b7d464bb3963a (patch) | |
| tree | ef1c072ec70cc95d3077c6dc10eff73be72366d8 /lua/user/dap.lua | |
| parent | f6e0aff4356dc2598966657895c777e6bea23d54 (diff) | |
Tidied up dap, and the handlers
Diffstat (limited to 'lua/user/dap.lua')
| -rw-r--r-- | lua/user/dap.lua | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/lua/user/dap.lua b/lua/user/dap.lua index b51dfd7..fb95eee 100644 --- a/lua/user/dap.lua +++ b/lua/user/dap.lua @@ -13,16 +13,44 @@ if not dap_ui_status_ok then return end -if not dap_install_status_ok then - return -end - dap_install.setup({ installation_path = vim.fn.stdpath('data') .. "/dapinstall/", }) dap_install.config("python", {}) +--dap setup + +dap.adapters.python = { + type = 'executable'; + command = 'python'; + args = { '-m', 'debugpy.adapter' }; +} +dap.configurations.python = { + { + -- The first three options are required by nvim-dap + type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python` + request = 'launch'; + name = "Launch file"; + + -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options + + program = "${file}"; -- This configuration will launch the current file if used. + pythonPath = function() + -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. + -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. + -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. + local cwd = vim.fn.getcwd() + if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then + return cwd .. '/venv/bin/python' + elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then + return cwd .. '/.venv/bin/python' + else + return '/usr/bin/python' + end + end; + }, +} -- dapui.setup() dapui.setup({ icons = { expanded = "▾", collapsed = "▸" }, |
