dap.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. local M = {}
  2. M.config = function()
  3. lvim.builtin.dap = {
  4. active = false,
  5. on_config_done = nil,
  6. breakpoint = {
  7. text = "",
  8. texthl = "LspDiagnosticsSignError",
  9. linehl = "",
  10. numhl = "",
  11. },
  12. breakpoint_rejected = {
  13. text = "",
  14. texthl = "LspDiagnosticsSignHint",
  15. linehl = "",
  16. numhl = "",
  17. },
  18. stopped = {
  19. text = "",
  20. texthl = "LspDiagnosticsSignInformation",
  21. linehl = "DiagnosticUnderlineInfo",
  22. numhl = "LspDiagnosticsSignInformation",
  23. },
  24. }
  25. end
  26. M.setup = function()
  27. local dap = require "dap"
  28. vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint)
  29. vim.fn.sign_define("DapBreakpointRejected", lvim.builtin.dap.breakpoint_rejected)
  30. vim.fn.sign_define("DapStopped", lvim.builtin.dap.stopped)
  31. dap.defaults.fallback.terminal_win_cmd = "50vsplit new"
  32. lvim.builtin.which_key.mappings["d"] = {
  33. name = "Debug",
  34. t = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" },
  35. b = { "<cmd>lua require'dap'.step_back()<cr>", "Step Back" },
  36. c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
  37. C = { "<cmd>lua require'dap'.run_to_cursor()<cr>", "Run To Cursor" },
  38. d = { "<cmd>lua require'dap'.disconnect()<cr>", "Disconnect" },
  39. g = { "<cmd>lua require'dap'.session()<cr>", "Get Session" },
  40. i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" },
  41. o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" },
  42. u = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" },
  43. p = { "<cmd>lua require'dap'.pause.toggle()<cr>", "Pause" },
  44. r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" },
  45. s = { "<cmd>lua require'dap'.continue()<cr>", "Start" },
  46. q = { "<cmd>lua require'dap'.close()<cr>", "Quit" },
  47. }
  48. if lvim.builtin.dap.on_config_done then
  49. lvim.builtin.dap.on_config_done(dap)
  50. end
  51. end
  52. -- TODO put this up there ^^^ call in ftplugin
  53. -- M.dap = function()
  54. -- if lvim.plugin.dap.active then
  55. -- local dap_install = require "dap-install"
  56. -- dap_install.config("python_dbg", {})
  57. -- end
  58. -- end
  59. --
  60. -- M.dap = function()
  61. -- -- gem install readapt ruby-debug-ide
  62. -- if lvim.plugin.dap.active then
  63. -- local dap_install = require "dap-install"
  64. -- dap_install.config("ruby_vsc_dbg", {})
  65. -- end
  66. -- end
  67. return M