Advertisement
Goodevil95

DAP configuration

Jul 13th, 2020
1,300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. local dap = require 'dap'
  2.  
  3. dap.adapters.cpp = {
  4.   attach = {
  5.     pidProperty = "pid",
  6.     pidSelect = "ask"
  7.   },
  8.   command = 'lldb-vscode',
  9.   env = {
  10.     LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY = "YES"
  11.   },
  12.   name = "lldb"
  13. }
  14.  
  15. vim.cmd [[
  16.     command! -complete=file -nargs=* DebugLLDB lua require "dap_config".start_lldb({<f-args>})
  17. ]]
  18.  
  19. local M = {}
  20.  
  21. local function current_env()
  22.   local variables = {}
  23.   for k, v in pairs(vim.fn.environ()) do
  24.     table.insert(variables, string.format("%s=%s", k, v))
  25.   end
  26.   return variables
  27. end
  28.  
  29. M.start_lldb = function(args)
  30.   local config = {
  31.     type = "cpp",
  32.     name = args[1],
  33.     request = "launch",
  34.     program = table.remove(args, 1),
  35.     args = args,
  36.     env = current_env(),
  37.     cwd = vim.fn.getcwd(),
  38.     MIMode = "gdb",
  39.   }
  40.  
  41.   dap.launch(dap.adapters.cpp, config)
  42.   dap.repl.open()
  43. end
  44.  
  45. return M
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement