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