debugging.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. return {
  2. "mfussenegger/nvim-dap",
  3. dependencies = {
  4. "rcarriga/nvim-dap-ui",
  5. "nvim-neotest/nvim-nio",
  6. },
  7. config = function()
  8. local dap, dapui = require("dap"), require("dapui")
  9. require("dapui").setup()
  10. dap.listeners.before.attach.dapui_config = function()
  11. dapui.open()
  12. end
  13. dap.listeners.before.launch.dapui_config = function()
  14. dapui.open()
  15. end
  16. dap.listeners.before.event_terminated.dapui_config = function()
  17. dapui.close()
  18. end
  19. dap.listeners.before.event_exited.dapui_config = function()
  20. dapui.close()
  21. end
  22. dap.adapters.lldb = {
  23. type = "executable",
  24. command = "/usr/bin/lldb-vscode",
  25. name = "lldb",
  26. }
  27. dap.configurations.rust = {
  28. {
  29. name = "Launch",
  30. type = "lldb",
  31. request = "launch",
  32. program = function()
  33. return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
  34. end,
  35. cwd = "${workspaceFolder}",
  36. stopOnEntry = false,
  37. args = {},
  38. initCommands = function()
  39. -- Find out where to look for the pretty printer Python module
  40. local rustc_sysroot = vim.fn.trim(vim.fn.system("rustc --print sysroot"))
  41. local script_import = 'command script import "'
  42. .. rustc_sysroot
  43. .. '/lib/rustlib/etc/lldb_lookup.py"'
  44. local commands_file = rustc_sysroot .. "/lib/rustlib/etc/lldb_commands"
  45. local commands = {}
  46. local file = io.open(commands_file, "r")
  47. if file then
  48. for line in file:lines() do
  49. table.insert(commands, line)
  50. end
  51. file:close()
  52. end
  53. table.insert(commands, 1, script_import)
  54. return commands
  55. end,
  56. },
  57. }
  58. end,
  59. }