return { { 'mfussenegger/nvim-dap', config = function() local dap = require("dap") dap.adapters.gdb = { type = "executable", command = "gdb", args = { "-i", "dap" } } dap.configurations.c = { { name = "Launch", type = "gdb", request = "launch", program = function() return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') end, cwd = "${workspaceFolder}", }, } dap.configurations.cpp = { { name = "Launch", type = "gdb", request = "launch", program = function() return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') end, cwd = "${workspaceFolder}", }, } 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/python3' end end; } } dap.adapters.python = function(cb, config) if config.request == 'attach' then ---@diagnostic disable-next-line: undefined-field local port = (config.connect or config).port ---@diagnostic disable-next-line: undefined-field local host = (config.connect or config).host or '127.0.0.1' cb({ type = 'server', port = assert(port, '`connect.port` is required for a python `attach` configuration'), host = host, options = { source_filetype = 'python', }, }) else cb({ type = 'executable', command = '/home/kmcr/.virtualenvs/debugpy/bin/python', args = { '-m', 'debugpy.adapter' }, options = { source_filetype = 'python', }, }) end end local def = { noremap = true, silent = true } vim.keymap.set('n', '\\c', function() require("dap").continue() end, def); vim.keymap.set('n', '\\b', function() require("dap").toggle_breakpoint() end, def); vim.keymap.set('n', '\\B', function() require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: ")) end, def); vim.keymap.set('n', '\\n', function() require("dap").step_over() end, def); vim.keymap.set('n', '\\s', function() require("dap").step_into() end, def); vim.keymap.set('n', '\\u', function() require("dap").step_out() end, def); vim.keymap.set('n', '\\l', function() require("dap").run_last() end, def); end }, { 'rcarriga/nvim-dap-ui', dependencies = { 'mfussenegger/nvim-dap' }, config = function() local ui = require('dapui') local dap = require('dap') local def = { noremap = true, silent = true } vim.keymap.set('n', '\\d', function() dap.continue() ui.toggle({}) end, def) vim.keymap.set('v', 'K', function() require("dapui").eval() end, def) ui.setup() end }, { 'theHamsta/nvim-dap-virtual-text', config = function() require("nvim-dap-virtual-text").setup{ enabled = true, -- enable this plugin (the default) enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination) highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables) show_stop_reason = true, -- show stop reason when stopped for exceptions commented = false, -- prefix virtual text with comment string only_first_definition = true, -- only show virtual text at first definition (if there are multiple) all_references = false, -- show virtual text on all all references of the variable (not only definitions) clear_on_continue = false, -- clear virtual text on "continue" (might cause flickering when stepping) --- A callback that determines how a variable is displayed or whether it should be omitted --- @param variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable --- @param buf number --- @param stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame --- @param node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`) --- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text --- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed display_callback = function(variable, buf, stackframe, node, options) if options.virt_text_pos == 'inline' then return ' = ' .. variable.value else return variable.name .. ' = ' .. variable.value end end, -- position of virtual text, see `:h nvim_buf_set_extmark()`, default tries to inline the virtual text. Use 'eol' to set to end of line virt_text_pos = vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol', -- experimental features: all_frames = false, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine. virt_lines = false, -- show virtual lines instead of virtual text (will flicker!) virt_text_win_col = nil -- position the virtual text at a fixed window column (starting from the first text column) , } end } }