diff options
author | Bobby Bingham <koorogi@koorogi.info> | 2022-07-10 00:11:00 -0500 |
---|---|---|
committer | Bobby Bingham <koorogi@koorogi.info> | 2022-07-10 11:03:01 -0500 |
commit | 4d1e79fe8026e77cdb97d0760176aa8305d48307 (patch) | |
tree | 62fa5273e348632d189971a5d7de89a83afc3c1e /nvim/.config | |
parent | c6b0a459c75dde02ffcdd57c63a7feb9c673b080 (diff) |
nvim: add dap plugins
Diffstat (limited to 'nvim/.config')
-rw-r--r-- | nvim/.config/nvim/lua/dap_config.lua | 59 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/dapui_config.lua | 54 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/plugins.lua | 20 |
3 files changed, 133 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) 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 = { "<tab>", "<2-LeftMouse>" }, -- default = "<cr>" + open = "<cr>", -- 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', + '<leader>dui', + function() require("dapui").toggle() end +) +vim.keymap.set( + {'n','v'}, + '<M-k>', + function() require("dapui").eval() end +) + +-- override key binding from dap_config, to ensure ui is shown when we start debugging +vim.keymap.set( + 'n', + '<F5>', + 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) |