From 4d1e79fe8026e77cdb97d0760176aa8305d48307 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Sun, 10 Jul 2022 00:11:00 -0500 Subject: nvim: add dap plugins --- nvim/.config/nvim/lua/dap_config.lua | 59 ++++++++++++++++++++++++++++++++++ nvim/.config/nvim/lua/dapui_config.lua | 54 +++++++++++++++++++++++++++++++ nvim/.config/nvim/lua/plugins.lua | 20 ++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 nvim/.config/nvim/lua/dap_config.lua create mode 100644 nvim/.config/nvim/lua/dapui_config.lua (limited to 'nvim') 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', '', function() require("dap").continue() end) +vim.keymap.set('n', '', function() require("dap").step_over() end) +vim.keymap.set('n', '', function() require("dap").step_into() end) +vim.keymap.set('n', '', function() require("dap").step_out() end) +vim.keymap.set('n', 'b', function() require("dap").toggle_breakpoint() end) +vim.keymap.set('n', 'B', function() require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: ")) end) +vim.keymap.set('n', 'lp', function() require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: ")) end) +vim.keymap.set('n', 'dr', function() require("dap").repl.open() end) +vim.keymap.set('n', 'dl', function() require("dap").run_last() end) diff --git a/nvim/.config/nvim/lua/dapui_config.lua b/nvim/.config/nvim/lua/dapui_config.lua new file mode 100644 index 0000000..0e2e433 --- /dev/null +++ b/nvim/.config/nvim/lua/dapui_config.lua @@ -0,0 +1,54 @@ +require('dapui').setup({ + mappings = { + -- Use a table to apply multiple mappings + expand = { "", "<2-LeftMouse>" }, -- default = "" + open = "", -- default = "o" + remove = "d", + edit = "e", + repl = "r", + toggle = "t", + }, + + layouts = { + { + elements = { + -- override default, keep scopes/stack next to each other + { id = "watches", size = 0.25 }, + "breakpoints", + "stacks", + "scopes", + }, + size = 40, -- 40 columns + position = "left", + }, + { + elements = { + "repl", + "console", + }, + size = 0.25, -- 25% of total lines + position = "bottom", + }, + }, +}) + +vim.keymap.set( + 'n', + 'dui', + function() require("dapui").toggle() end +) +vim.keymap.set( + {'n','v'}, + '', + function() require("dapui").eval() end +) + +-- override key binding from dap_config, to ensure ui is shown when we start debugging +vim.keymap.set( + 'n', + '', + function() + require("dapui").open() + require("dap").continue() + end +) diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 18d0fd0..1baa9dc 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -77,5 +77,25 @@ return require('packer').startup(function() requires = 'nvim-lua/plenary.nvim', config = function() require('neorg_config') end } + + use { + 'mfussenegger/nvim-dap', + config = function() require('dap_config') end + } + + use { + 'rcarriga/nvim-dap-ui', + requires = 'mfussenegger/nvim-dap', + config = function() require("dapui_config") end, + } + + use { + 'theHamsta/nvim-dap-virtual-text', + requires = { + 'mfussenegger/nvim-dap', + 'nvim-treesitter/nvim-treesitter', + }, + config = function() require("nvim-dap-virtual-text").setup() end, + } end) -- cgit v1.2.3