debug.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. -- debug.lua
  2. --
  3. -- Shows how to use the DAP plugin to debug your code.
  4. --
  5. -- Primarily focused on configuring the debugger for Go, but can
  6. -- be extended to other languages as well. That's why it's called
  7. -- kickstart.nvim and not kitchen-sink.nvim ;)
  8. return {
  9. -- NOTE: Yes, you can install new plugins here!
  10. 'mfussenegger/nvim-dap',
  11. -- NOTE: And you can specify dependencies as well
  12. dependencies = {
  13. -- Creates a beautiful debugger UI
  14. 'rcarriga/nvim-dap-ui',
  15. -- Installs the debug adapters for you
  16. 'williamboman/mason.nvim',
  17. 'jay-babu/mason-nvim-dap.nvim',
  18. -- Add your own debuggers here
  19. 'leoluz/nvim-dap-go',
  20. },
  21. config = function()
  22. local dap = require 'dap'
  23. local dapui = require 'dapui'
  24. require('mason-nvim-dap').setup {
  25. -- Makes a best effort to setup the various debuggers with
  26. -- reasonable debug configurations
  27. automatic_setup = true,
  28. -- You'll need to check that you have the required things installed
  29. -- online, please don't ask me how to install them :)
  30. ensure_installed = {
  31. -- Update this to ensure that you have the debuggers for the langs you want
  32. 'delve',
  33. },
  34. }
  35. -- You can provide additional configuration to the handlers,
  36. -- see mason-nvim-dap README for more information
  37. require('mason-nvim-dap').setup_handlers()
  38. -- Basic debugging keymaps, feel free to change to your liking!
  39. vim.keymap.set('n', '<F5>', dap.continue)
  40. vim.keymap.set('n', '<F1>', dap.step_into)
  41. vim.keymap.set('n', '<F2>', dap.step_over)
  42. vim.keymap.set('n', '<F3>', dap.step_out)
  43. vim.keymap.set('n', '<leader>b', dap.toggle_breakpoint)
  44. vim.keymap.set('n', '<leader>B', function()
  45. dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
  46. end)
  47. -- Dap UI setup
  48. -- For more information, see |:help nvim-dap-ui|
  49. dapui.setup {
  50. -- Set icons to characters that are more likely to work in every terminal.
  51. -- Feel free to remove or use ones that you like more! :)
  52. -- Don't feel like these are good choices.
  53. icons = { expanded = '▾', collapsed = '▸', current_frame = '*' },
  54. controls = {
  55. icons = {
  56. pause = '⏸',
  57. play = '▶',
  58. step_into = '⏎',
  59. step_over = '⏭',
  60. step_out = '⏮',
  61. step_back = 'b',
  62. run_last = '▶▶',
  63. terminate = '⏹',
  64. },
  65. },
  66. }
  67. dap.listeners.after.event_initialized['dapui_config'] = dapui.open
  68. dap.listeners.before.event_terminated['dapui_config'] = dapui.close
  69. dap.listeners.before.event_exited['dapui_config'] = dapui.close
  70. -- Install golang specific config
  71. require('dap-go').setup()
  72. end,
  73. }