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