dap.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. if lvim.use_icons then
  29. vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint)
  30. vim.fn.sign_define("DapBreakpointRejected", lvim.builtin.dap.breakpoint_rejected)
  31. vim.fn.sign_define("DapStopped", lvim.builtin.dap.stopped)
  32. end
  33. dap.defaults.fallback.terminal_win_cmd = "50vsplit new"
  34. lvim.builtin.which_key.mappings["d"] = {
  35. name = "Debug",
  36. t = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" },
  37. b = { "<cmd>lua require'dap'.step_back()<cr>", "Step Back" },
  38. c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
  39. C = { "<cmd>lua require'dap'.run_to_cursor()<cr>", "Run To Cursor" },
  40. d = { "<cmd>lua require'dap'.disconnect()<cr>", "Disconnect" },
  41. g = { "<cmd>lua require'dap'.session()<cr>", "Get Session" },
  42. i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" },
  43. o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" },
  44. u = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" },
  45. p = { "<cmd>lua require'dap'.pause()<cr>", "Pause" },
  46. r = { "<cmd>lua require'dap'.repl.toggle()<cr>", "Toggle Repl" },
  47. s = { "<cmd>lua require'dap'.continue()<cr>", "Start" },
  48. q = { "<cmd>lua require'dap'.close()<cr>", "Quit" },
  49. }
  50. if lvim.builtin.dap.on_config_done then
  51. lvim.builtin.dap.on_config_done(dap)
  52. end
  53. end
  54. -- TODO put this up there ^^^ call in ftplugin
  55. -- M.dap = function()
  56. -- if lvim.plugin.dap.active then
  57. -- local dap_install = require "dap-install"
  58. -- dap_install.config("python_dbg", {})
  59. -- end
  60. -- end
  61. --
  62. -- M.dap = function()
  63. -- -- gem install readapt ruby-debug-ide
  64. -- if lvim.plugin.dap.active then
  65. -- local dap_install = require "dap-install"
  66. -- dap_install.config("ruby_vsc_dbg", {})
  67. -- end
  68. -- end
  69. return M