Advertisement
Goodevil95

Untitled

Jul 13th, 2020
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. local M = {}
  2. local last_gdb_config
  3.  
  4. M.start_c_debugger = function(args, mi_mode, mi_debugger_path)
  5.     local dap = require "dap"
  6.     if args and #args > 0 then
  7.         last_gdb_config = {
  8.             type = "cpp",
  9.             name = args[1],
  10.             request = "launch",
  11.             program = table.remove(args, 1),
  12.             args = args,
  13.             env = function()
  14.               local variables = {}
  15.               for k, v in pairs(vim.fn.environ()) do
  16.                 table.insert(variables, string.format("%s=%s", k, v))
  17.               end
  18.               return variables
  19.             end,
  20.             cwd = vim.fn.getcwd(),
  21.             environment = {},
  22.             externalConsole = true,
  23.             MIMode = mi_mode or "gdb",
  24.             MIDebuggerPath = mi_debugger_path
  25.           }
  26.     end
  27.  
  28.     if not last_gdb_config then
  29.         print('No binary to debug set! Use ":DebugC <binary> <args>" or ":DebugRust <binary> <args>"')
  30.         return
  31.     end
  32.  
  33.     dap.launch(dap.adapters.cpp, last_gdb_config)
  34.     dap.repl.open()
  35. end
  36.  
  37. return M
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement