From 49f849407268d96cf3fe05ab7f8558727f8b3ee3 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 6 Aug 2022 15:26:18 +0200 Subject: [PATCH] first running verion of dab python --- .gitignore | 1 + lua/setup/my_dap.lua | 66 ++++++++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index d87f6b4..62b7e09 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ vim.bundle plugged rplugin.vim plugin/packer_compiled.lua +venv_debugpy diff --git a/lua/setup/my_dap.lua b/lua/setup/my_dap.lua index a969c1e..e891040 100644 --- a/lua/setup/my_dap.lua +++ b/lua/setup/my_dap.lua @@ -10,35 +10,41 @@ vim.keymap.set('n', '', ":lua require('dap').step_out()", opts) -- vim.keymap.set('n', '', dap.step_into(), opts) -- vim.keymap.set('n', '', dap.step_out(), opts) -dap.adapters.python = { - type = 'executable'; - command = 'C:/Users/oli/AppData/Local/nvim-data/mason/packages/debugpy/venv/Scripts/python.exe'; - 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; - }, -} +-- dap.adapters.python = { +-- type = 'executable'; +-- command = 'C:\\Users\\oli\\AppData\\Local\\nvim\\venv_debugpy\\Scripts\\python'; +-- args = { '-m', 'debugpy.adapter' }; +-- options = { +-- detached = true; +-- }; +-- } +-- 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 venv = os.getenv("VIRTUAL_ENV") +-- return string.format("%s\\bin\\python.exe",venv) +-- -- 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; +-- }, +-- } +require('dap-python').setup('C:\\Users\\oli\\AppData\\Local\\nvim\\venv_debugpy\\Scripts\\python') -- require('dap-python').setup('C:/Users/oli/AppData/Local/nvim-data/mason/packages/debugpy/venv/Scripts/python.exe')