From 3d9cd7098a41c335d1a3b9a893a290a9580f305b Mon Sep 17 00:00:00 2001 From: Amanda Graven Date: Thu, 18 Aug 2022 12:15:48 +0200 Subject: [PATCH] Add nvim-dap --- init.lua | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 113 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 4482cef..4d9a34a 100644 --- a/init.lua +++ b/init.lua @@ -245,7 +245,7 @@ require'packer'.startup(function(use) vim.g['test#neovim#term_position'] = 'vert' vim.g['test#strategy'] = 'neovim' end} - use {'julian/vim-textobj-variable-segment', requires = {'kana/vim-textobj-user'}} + use {'julian/vim-textobj-variable-segment', requires = {'kana/vim-textobj-user'}, branch = 'main'} use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'} use 'hrsh7th/vim-vsnip' @@ -274,6 +274,97 @@ require'packer'.startup(function(use) use {'MattesGroeger/vim-bookmarks', config = function() vim.g.bookmark_save_per_working_dir = 1 end} + use {'mfussenegger/nvim-dap', config = function() + local dap = require'dap' + dap.adapters.codelldb = { + type = 'server', + port = '${port}', + executable = { + command = vim.fn.stdpath('data') .. '/mason/packages/codelldb/extension/adapter/codelldb', + args = {'--port', '${port}'}, + }, + } + dap.configurations.cpp = { + { + name = 'Launch file', + type = 'codelldb', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = true, + }, + } + dap.configurations.rust = dap.configurations.cpp + dap.configurations.c = dap.configurations.c + require'which-key'.register { + ['d'] = { + name = 'Debug', + c = {dap.continue, 'Continue/start'}, + s = {dap.terminate, 'Stop'}, + b = {dap.toggle_breakpoint, 'Breakpoint'}, + o = {dap.step_over, 'Step over'}, + i = {dap.step_into, 'Step into'}, + O = {dap.step_out, 'Step out'}, + r = {dap.step_back, 'Step back'}, + R = {dap.reverse_continue, 'Continue backwards'}, + C = {dap.run_to_cursor, 'Continue to cursor'}, + p = {dap.paise, 'Pause execution'} + } + } + end} + use {'rcarriga/nvim-dap-ui', config = function() + require'dapui'.setup() + require'which-key'.register { + ['dd'] = {require'dapui'.toggle, 'Debug'} + } + end} + use {'theHamsta/nvim-dap-virtual-text', config = function() + require'nvim-dap-virtual-text'.setup{} + end} + use {'mxsdev/nvim-dap-vscode-js', requires = {'mfussenegger/nvim-dap'}, config = function() + require'dap-vscode-js'.setup { + adapters = {'pwa-node', 'node-terminal'}, + } + for _, language in ipairs({'javascript', 'typescript'}) do + require'dap'.configurations[language] = { + { + type = 'pwa-node', + request = 'launch', + name = 'Launch file', + program = '${file}', + cwd = '${workspaceFolder}', + }, + { + type = 'pwa-node', + request = 'attach', + name = 'Attach', + processId = require'dap.utils'.pick_process, + cwd = '${workspaceFolder}', + }, + { + type = 'pwa-node', + request = 'launch', + name = 'Debug Mocha Tests', + -- trace = true, -- include debugger info + runtimeExecutable = 'node', + runtimeArgs = { + './node_modules/mocha/bin/mocha', + }, + rootPath = '${workspaceFolder}', + cwd = '${workspaceFolder}', + console = 'integratedTerminal', + internalConsoleOptions = 'neverOpen', + } + } + end + end} + use { + 'microsoft/vscode-js-debug', + opt = true, + run = 'npm install --legacy-peer-deps && npm run compile' + } use {'stevearc/dressing.nvim', config = function() vim.cmd'highlight link FloatTitle TelescopeBorder' require'dressing'.setup { @@ -297,6 +388,14 @@ require'packer'.startup(function(use) require'lsp_lines'.setup() vim.diagnostic.config { virtual_text = false } end} + use {'williamboman/mason.nvim', config = function() + require'mason'.setup() + end} + use {'williamboman/mason-lspconfig.nvim', config = function() + require'mason-lspconfig'.setup { + automatic_installation = true, + } + end} use {'rcarriga/nvim-notify', after = 'telescope.nvim', config = function () require'notify'.setup { stages = 'fade' @@ -372,6 +471,9 @@ require'packer'.startup(function(use) use {'nvim-telescope/telescope-ui-select.nvim', config = function () require'telescope'.load_extension('ui-select') end} + use {'nvim-telescope/telescope-dap.nvim', after = 'telescope.nvim', config = function() + require'telescope'.load_extension'dap' + end} use 'kyazdani42/nvim-tree.lua' use 'simrat39/symbols-outline.nvim' use {'folke/which-key.nvim', config = function() require'which-key'.setup() end} @@ -672,10 +774,16 @@ require'rust-tools'.setup { procMacro = { -- Enable proc macro support enable = true, - } - } - } - } + }, + }, + }, + }, + dap = { + adapter = require'rust-tools.dap'.get_codelldb_adapter( + vim.fn.stdpath('data') .. '/mason/packages/codelldb/extension/adapter/codelldb', + vim.fn.stdpath('data') .. '/mason/packages/codelldb/extension/lldb/lib/liblldb.so' + ) + }, }