nvim-config

Log | Files | Refs | Submodules | README

dap-config.lua (1795B)


      1 local dap = require('dap')
      2 dap.adapters.cppdbg = {
      3   id = 'cppdbg',
      4   type = 'executable',
      5   command = 'OpenDebugAD7',
      6 }
      7 
      8 dap.configurations.cpp = {
      9   {
     10     name = "Launch file",
     11     type = "cppdbg",
     12     request = "launch",
     13     program = function()
     14       return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
     15     end,
     16     args = function()
     17       local args_string = vim.fn.input('Arguments: ', "", "file")
     18       return vim.split(args_string, " +")
     19     end,
     20     cwd = '${workspaceFolder}',
     21     stopOnEntry = true,
     22   },
     23 }
     24 
     25 -- If you want to use this for Rust and C, add something like this:
     26 
     27 dap.configurations.c = dap.configurations.cpp
     28 dap.configurations.rust = dap.configurations.cpp
     29 
     30 dap.defaults.fallback.external_terminal = {
     31   command = vim.fn.exepath "st";
     32   args = { '-e' };
     33 }
     34 dap.defaults.fallback.force_external_terminal = true
     35 
     36 local widgets = require "dap.ui.widgets"
     37 
     38 local sbar = widgets.sidebar(widgets.frames)
     39 
     40 dap.listeners.after['event_initialized']['me'] = function()
     41 end
     42 
     43 dap.listeners.after['event_terminated']['me'] = function()
     44 end
     45 
     46 vim.keymap.set("n", "<LocalLeader>r", dap.continue)
     47 vim.keymap.set("n", "<LocalLeader>n", dap.step_over)
     48 vim.keymap.set("n", "<LocalLeader>s", dap.step_into)
     49 vim.keymap.set("n", "<LocalLeader>o", dap.step_out)
     50 vim.keymap.set("n", "<LocalLeader>b", dap.toggle_breakpoint)
     51 vim.keymap.set("n", "<LocalLeader>u", dap.up)
     52 vim.keymap.set("n", "<LocalLeader>d", dap.down)
     53 vim.keymap.set({"n", "v"}, "<LocalLeader><LocalLeader>", widgets.hover)
     54 vim.keymap.set("n", "<LocalLeader>ib", function()
     55   dap.set_breakpoint(vim.fn.input('Breakpoint condition: '))
     56 end)
     57 vim.keymap.set("n", "<LocalLeader>lb", function()
     58   dap.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))
     59 end)
     60 
     61 require("nvim-dap-virtual-text").setup()