From 652a1c2aa7510382aa323c0742ad77b31c1737d0 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 13 Aug 2022 13:41:12 +0200 Subject: [PATCH] fixed dap python config --- lua/setup/my_dap.lua | 79 +++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/lua/setup/my_dap.lua b/lua/setup/my_dap.lua index 43bcf4a..a7b6a52 100644 --- a/lua/setup/my_dap.lua +++ b/lua/setup/my_dap.lua @@ -6,18 +6,19 @@ vim.keymap.set('n', '', ":lua require('dap').toggle_breakpoint()", opts) vim.keymap.set('n', '', ":lua require('dap').step_over()", opts) vim.keymap.set('n', '', ":lua require('dap').step_into()", opts) vim.keymap.set('n', '', ":lua require('dap').step_out()", opts) --- vim.keymap.set('n', '', dap.step_over(), 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\\venv_debugpy\\Scripts\\python'; --- args = { '-m', 'debugpy.adapter' }; --- options = { --- detached = true; --- }; --- } +local initDir = vim.api.nvim_list_runtime_paths()[1] + +-- PYTHON +dap.adapters.python = { + type = 'executable'; + command = initDir .. '/venv_debugpy/Scripts/python'; + args = { '-m', 'debugpy.adapter' }; + options = { + detached = true; + }; +} + local dap, dapui = require("dap"), require("dapui") dap.listeners.after.event_initialized["dapui_config"] = function() dapui.open() @@ -29,7 +30,6 @@ dap.listeners.before.event_exited["dapui_config"] = function() dapui.close() end - local function getVenvSuffix() if vim.loop.os_uname().sysname == 'Linux' then return 'bin/python' @@ -38,11 +38,10 @@ local function getVenvSuffix() end end -function getPythonEnv() - +local function getPythonEnv() local venv = os.getenv("VIRTUAL_ENV") if venv ~= nil then - return string.format("%s\\bin\\python.exe",venv) + return string.format("%s\\bin\\python.exe", venv) end local cwd = vim.fn.getcwd() @@ -66,25 +65,45 @@ dap.configurations.python = { name = "Launch file with venv"; justMyCode = false; program = "${file}"; - pythonPath = getPythonEnv(); + pythonPath = function() + return getPythonEnv() + end; }, } -require('dap-python').setup('C:\\Users\\oli\\AppData\\Local\\nvim\\venv_debugpy\\Scripts\\python') -table.insert(require('dap').configurations.python, { - -- type = 'python', - -- request = 'launch', - -- name = 'My custom launch configuration', - -- program = '${file}', - justMyCode = false - -- ... more options, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings -}) +-- require('dap-python').setup('C:\\Users\\oli\\AppData\\Local\\nvim\\venv_debugpy\\Scripts\\python') +-- table.insert(require('dap').configurations.python, { +-- -- type = 'python', +-- -- request = 'launch', +-- -- name = 'My custom launch configuration', +-- -- program = '${file}', +-- justMyCode = false +-- -- ... more options, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings +-- }) -- require('dap-python').setup('C:/Users/oli/AppData/Local/nvim-data/mason/packages/debugpy/venv/Scripts/python.exe') + +-- CPP +dap.adapters.codelldb = { + type = 'server', + port = "${port}", + executable = { + -- CHANGE THIS to your path! + command = '/absolute/path/to/codelldb/extension/adapter/codelldb', + args = { '--port', '${port}' }, + + -- On windows you may have to uncomment this: + -- detached = false, + } +} + + +-- EXTENSIONS + require("nvim-dap-virtual-text").setup() require('telescope').load_extension('dap') -require("cmp").setup.filetype({ "dap-repl", "dapui_watches" }, { - sources = { - { name = "dap" }, - }, -}) +-- require("cmp").setup.filetype({ "dap-repl", "dapui_watches" }, { +-- sources = { +-- { name = "dap" }, +-- }, +-- }) require("dapui").setup()