summaryrefslogtreecommitdiff
path: root/nvim/.config/nvim/lua/dap_config.lua
diff options
context:
space:
mode:
Diffstat (limited to 'nvim/.config/nvim/lua/dap_config.lua')
-rw-r--r--nvim/.config/nvim/lua/dap_config.lua59
1 files changed, 59 insertions, 0 deletions
diff --git a/nvim/.config/nvim/lua/dap_config.lua b/nvim/.config/nvim/lua/dap_config.lua
new file mode 100644
index 0000000..3eabf00
--- /dev/null
+++ b/nvim/.config/nvim/lua/dap_config.lua
@@ -0,0 +1,59 @@
+local dap = require('dap')
+
+dap.adapters.node2 = {
+ type = 'executable',
+ command = 'node',
+ args = {os.getenv('HOME') .. '/src/vscode-node-debug2/out/src/nodeDebug.js'},
+}
+
+dap.configurations.javascript = {
+ {
+ name = 'Launch',
+ type = 'node2',
+ request = 'launch',
+ program = '${file}',
+ cwd = vim.fn.getcwd(),
+ sourceMaps = true,
+ protocol = 'inspector',
+ console = 'integratedTerminal',
+ },
+ {
+ -- For this to work you need to make sure the node process is started with the `--inspect` flag.
+ name = 'Attach to process',
+ type = 'node2',
+ request = 'attach',
+ processId = require'dap.utils'.pick_process,
+ },
+}
+
+dap.configurations.typescript = {
+ {
+ name = 'Launch',
+ type = 'node2',
+ request = 'launch',
+ --program = '${fileDirname}/${fileBasenameNoExtention}.js',
+ program = '${file}',
+ outFiles = { '${workspaceFolder}/**/*.js' },
+ cwd = vim.fn.getcwd(),
+ sourceMaps = true,
+ protocol = 'inspector',
+ console = 'integratedTerminal',
+ },
+ {
+ -- For this to work you need to make sure the node process is started with the `--inspect` flag.
+ name = 'Attach to process',
+ type = 'node2',
+ request = 'attach',
+ processId = require'dap.utils'.pick_process,
+ },
+}
+
+vim.keymap.set('n', '<F5>', function() require("dap").continue() end)
+vim.keymap.set('n', '<F10>', function() require("dap").step_over() end)
+vim.keymap.set('n', '<F11>', function() require("dap").step_into() end)
+vim.keymap.set('n', '<F12>', function() require("dap").step_out() end)
+vim.keymap.set('n', '<Leader>b', function() require("dap").toggle_breakpoint() end)
+vim.keymap.set('n', '<Leader>B', function() require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: ")) end)
+vim.keymap.set('n', '<Leader>lp', function() require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: ")) end)
+vim.keymap.set('n', '<Leader>dr', function() require("dap").repl.open() end)
+vim.keymap.set('n', '<Leader>dl', function() require("dap").run_last() end)