local M = {} -- DAP: Debug Adapter Protocol >>> M.nvim_dap = function() local dap = require('dap') -- keybinds vim.cmd [[ " Debugger movement nnoremap d lua require'dap'.continue() nnoremap dj lua require'dap'.step_over() nnoremap dl lua require'dap'.step_into() nnoremap dh lua require'dap'.step_out() " Breakpoints nnoremap dbb lua require'dap'.toggle_breakpoint() nnoremap dbc lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition ')) nnoremap dbl lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message ')) " Extra nnoremap dp lua require'dap'.run_last() nnoremap dr lua require'dap'.repl.open() nnoremap dq lua require'dap'.close() ]] require("dap") vim.fn.sign_define('DapBreakpoint', {text = '綠', texthl = 'ErrorMsg', linehl = '', numhl = ''}) -- custom attributes of breakpointed lines (use an emoji?) vim.fn.sign_define('DapBreakpointRejected', {text = '祿', texthl = 'ErrorMsg', linehl = '', numhl = ''}) vim.fn.sign_define('DapLogPoint', {text = ' ', texthl = 'ErrorMsg', linehl = '', numhl = ''}) vim.fn.sign_define('DapStopped', {text = '→ ', texthl = 'String', linehl = '', numhl = ''}) vim.cmd "au FileType dap-repl lua require('dap.ext.autocompl').attach()" -- dap configuration dap.defaults.fallback.terminal_win_cmd = "10new" -- per-language config: -- c++ dap congiguration >>> dap.configurations.cpp = { { name = "Launch file", type = "cppdbg", request = "launch", program = function() return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') end, cwd = '${workspaceFolder}', stopOnEntry = true, }, } dap.adapters.cppdbg = { type = 'executable', command = '/home/blake/.local/share/nvim/dapinstall/ccppr_vsc/extension/debugAdapters/bin/OpenDebugAD7', } -- <<< end -- <<< -- DAP installer >>> M.dap_buddy = function() require("dap_buddy").setup({ installation_path = vim.fn.stdpath("data") .. "/dap_buddy/", }) end -- <<< -- UI for nvim-dap >>> M.dap_ui = function() -- external keybinds -- require("dapui").open() -- require("dapui").close() -- require("dapui").toggle() -- toggle dap-ui with leader di as in dap interface vim.cmd 'nnoremap di lua require("dapui").toggle("sidebar")' require("dapui").setup({ icons = { expanded = "▾", collapsed = "▸" }, mappings = { expand = { "l", "h", "", "<2-LeftMouse>", }, -- expand (or close) open = "o", -- action depends on the dap server remove = "d", -- delete the variable edit = "s", -- (as in substitute) repl = "r", -- open a repl }, windows = { indent = 1 }, }) end -- <<< -- dap-virtual-text: show values of variables inline while debugging >>> M.dap_vtext = function() require'nvim-dap-virtual-text' -- virtual text deactivated (default) vim.g.dap_virtual_text = true -- show virtual text for current frame (recommended) vim.g.dap_virtual_text = true -- request variable values for all frames (experimental) vim.g.dap_virtual_text = 'all frames' end -- <<< return M -- vim:fdm=marker:fmr=>>>,<<<:expandtab:tabstop=3:sw=3