local M = {} -- DAP: Debug Adapter Protocol >>> M.nvim_dap = function() -- 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() ]] 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 local dap = require('dap') 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_install = function() require("dap-install").setup({ installation_path = vim.fn.stdpath("data") .. "/dapinstall/", }) 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()' 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 }, sidebar = { -- You can change the order of elements in the sidebar elements = { -- size can be float or integer > 1 { id = "scopes", size = 0.55, }, { id = "breakpoints", size = 0.15 }, { id = "stacks", size = 0.15 }, { id = "watches", size = 0.15 }, }, size = 40, position = "left", -- Can be "left", "right", "top", "bottom" }, -- tray = { -- elements = { "repl" }, -- size = 10, -- position = "bottom", -- Can be "left", "right", "top", "bottom" -- }, floating = { max_height = nil, -- These can be integers or a float between 0 and 1. max_width = nil, -- Floats will be treated as percentage of your screen. mappings = { close = { "q", "" }, }, }, 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