this repo has no description
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
9return {
10 -- NOTE: Yes, you can install new plugins here!
11 'mfussenegger/nvim-dap',
12 -- NOTE: And you can specify dependencies as well
13 dependencies = {
14 -- Creates a beautiful debugger UI
15 'rcarriga/nvim-dap-ui',
16
17 -- Installs the debug adapters for you
18 'williamboman/mason.nvim',
19 'jay-babu/mason-nvim-dap.nvim',
20
21 -- Add your own debuggers here
22 'leoluz/nvim-dap-go',
23 },
24 config = function()
25 local dap = require 'dap'
26 local dapui = require 'dapui'
27
28 require('mason-nvim-dap').setup {
29 -- Makes a best effort to setup the various debuggers with
30 -- reasonable debug configurations
31 automatic_setup = true,
32
33 -- You can provide additional configuration to the handlers,
34 -- see mason-nvim-dap README for more information
35 handlers = {},
36
37 -- You'll need to check that you have the required things installed
38 -- online, please don't ask me how to install them :)
39 ensure_installed = {
40 -- Update this to ensure that you have the debuggers for the langs you want
41 'delve',
42 },
43 }
44
45 -- Basic debugging keymaps, feel free to change to your liking!
46 vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
47 vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' })
48 vim.keymap.set('n', '<F2>', dap.step_over, { desc = 'Debug: Step Over' })
49 vim.keymap.set('n', '<F3>', dap.step_out, { desc = 'Debug: Step Out' })
50 vim.keymap.set('n', '<leader>b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' })
51 vim.keymap.set('n', '<leader>B', function()
52 dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
53 end, { desc = 'Debug: Set Breakpoint' })
54
55 -- Dap UI setup
56 -- For more information, see |:help nvim-dap-ui|
57 dapui.setup {
58 -- Set icons to characters that are more likely to work in every terminal.
59 -- Feel free to remove or use ones that you like more! :)
60 -- Don't feel like these are good choices.
61 icons = { expanded = '▾', collapsed = '▸', current_frame = '*' },
62 controls = {
63 icons = {
64 pause = '⏸',
65 play = '▶',
66 step_into = '⏎',
67 step_over = '⏭',
68 step_out = '⏮',
69 step_back = 'b',
70 run_last = '▶▶',
71 terminate = '⏹',
72 disconnect = '⏏',
73 },
74 },
75 }
76
77 -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
78 vim.keymap.set('n', '<F7>', dapui.toggle, { desc = 'Debug: See last session result.' })
79
80 dap.listeners.after.event_initialized['dapui_config'] = dapui.open
81 dap.listeners.before.event_terminated['dapui_config'] = dapui.close
82 dap.listeners.before.event_exited['dapui_config'] = dapui.close
83
84 -- Install golang specific config
85 require('dap-go').setup()
86 end,
87}