Advertisement
Goodevil95

Untitled

Jun 26th, 2020
1,999
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 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.             cwd = vim.fn.getcwd(),
  14.             environment = {},
  15.             externalConsole = true,
  16.             MIMode = mi_mode or "gdb",
  17.             MIDebuggerPath = mi_debugger_path
  18.           }
  19.     end
  20.  
  21.     if not last_gdb_config then
  22.         print('No binary to debug set! Use ":DebugC <binary> <args>" or ":DebugRust <binary> <args>"')
  23.         return
  24.     end
  25.  
  26.     dap.launch(dap.adapters.cpp, last_gdb_config)
  27.     dap.repl.open()
  28. end
  29.  
  30. return M
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement