]> git.r.bdr.sh - rbdr/dotfiles/blob - config/nvim/lua/dap_config.lua
Add DAP
[rbdr/dotfiles] / config / nvim / lua / dap_config.lua
1 local dap = require('dap')
2
3 dap.adapters.node2 = {
4 type = 'executable',
5 command = 'node',
6 args = {os.getenv('HOME') .. '/projects/tools/vscode-node-debug2/out/src/nodeDebug.js'},
7 }
8 dap.configurations.javascript = {
9 {
10 name = 'Launch',
11 type = 'node2',
12 request = 'launch',
13 program = '${file}',
14 cwd = vim.fn.getcwd(),
15 sourceMaps = true,
16 protocol = 'inspector',
17 console = 'integratedTerminal',
18 },
19 {
20 -- For this to work you need to make sure the node process is started with the `--inspect` flag.
21 name = 'Attach to process',
22 type = 'node2',
23 request = 'attach',
24 processId = require'dap.utils'.pick_process,
25 },
26 }
27
28 dap.adapters.firefox = {
29 type = 'executable',
30 command = 'node',
31 args = {os.getenv('HOME') .. '/projects/tools/vscode-firefox-debug/dist/adapter.bundle.js'},
32 }
33
34 dap.configurations.typescript = {
35 {
36 name = 'Debug with Firefox',
37 type = 'firefox',
38 request = 'launch',
39 reAttach = true,
40 url = 'http://localhost:3000',
41 webRoot = '${workspaceFolder}',
42 firefoxExecutable = '/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox'
43 }
44 }
45
46 dap.configurations.typescriptreact = {
47 {
48 name = 'Debug with Firefox',
49 type = 'firefox',
50 request = 'launch',
51 reAttach = true,
52 url = 'http://localhost:3000',
53 webRoot = '${workspaceFolder}',
54 firefoxExecutable = '/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox'
55 }
56 }
57
58 dap.adapters.python = function(cb, config)
59 if config.request == 'attach' then
60 ---@diagnostic disable-next-line: undefined-field
61 local port = (config.connect or config).port
62 ---@diagnostic disable-next-line: undefined-field
63 local host = (config.connect or config).host or '127.0.0.1'
64 cb({
65 type = 'server',
66 port = assert(port, '`connect.port` is required for a python `attach` configuration'),
67 host = host,
68 options = {
69 source_filetype = 'python',
70 },
71 })
72 else
73 cb({
74 type = 'executable',
75 command = os.getenv('HOME') .. '/.asdf/shims/python',
76 args = { '-m', 'debugpy.adapter' },
77 options = {
78 source_filetype = 'python',
79 },
80 })
81 end
82 end
83
84 dap.configurations.python = {
85 {
86 -- The first three options are required by nvim-dap
87 type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python`
88 request = 'launch';
89 name = "Launch file";
90
91 -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
92
93 program = "${file}"; -- This configuration will launch the current file if used.
94 pythonPath = function()
95 -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
96 -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
97 -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
98 local cwd = vim.fn.getcwd()
99 if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
100 return cwd .. '/venv/bin/python'
101 elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
102 return cwd .. '/.venv/bin/python'
103 else
104 return os.getenv('HOME') .. '/.asdf/shims/python'
105 end
106 end;
107 },
108 }
109
110 require('neodev').setup({
111 library = { plugins = { "nvim-dap-ui" }, types = true }
112 })