diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-10-24 21:58:54 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-10-24 21:58:54 +0200 |
commit | ddefe1a4d3963fec2d5b640bb8cd39cef8872b3b (patch) | |
tree | a1ec3a69918a11742571ddc09cf3ab3dff62ef88 | |
parent | 221204e376a1f17300704f7d615ca12a6f644f57 (diff) |
Add test with nvim-dap
-rw-r--r-- | .config/nvim/init.lua | 6 | ||||
-rw-r--r-- | .config/nvim/lua/test-dap.lua | 30 |
2 files changed, 36 insertions, 0 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 8fb4457..faa58e1 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -43,6 +43,11 @@ require('packer').startup(function(use) use 'folke/lsp-colors.nvim' -- Adds missing LSP diagnostics highlight groups use 'sindrets/diffview.nvim' -- Git diff and history viewer + use 'mfussenegger/nvim-dap' -- Debug Adapter Protocol client implementation + use 'leoluz/nvim-dap-go' -- Neovim DAP extension for Go + -- use 'nvim-neotest/nvim-nio' + -- use 'rcarriga/nvim-dap-ui' + -- Automatically set up the configuration after cloning packer.nvim if packer_bootstrap then require('packer').sync() @@ -203,6 +208,7 @@ vim.cmd.highlight('clear @ibl.scope.underline.1') -- General settings require('git') -- Load git-related settings require('lsp_conf') -- Load LSP configuration +require('test-dap') -- Set up language client for Go vim.g.LanguageClient_serverCommands = { go = { 'gopls' } } diff --git a/.config/nvim/lua/test-dap.lua b/.config/nvim/lua/test-dap.lua new file mode 100644 index 0000000..4053c51 --- /dev/null +++ b/.config/nvim/lua/test-dap.lua @@ -0,0 +1,30 @@ +local dap, dapui = require('dap'), require('dapui') +local dapgo = require('dap-go') +dapui.setup() +dapgo.setup() +dap.listeners.before.attach.dapui_config = function() + dapui.open() +end +dap.listeners.before.launch.dapui_config = function() + dapui.open() +end + + +-- Include the next few lines until the comment only if you feel you need it +dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() +end +dap.listeners.before.event_exited.dapui_config = function() + dapui.close() +end +-- Include everything after this + + +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.api.nvim_create_user_command('Bk',function() require('dap').toggle_breakpoint() end, {}) +vim.api.nvim_create_user_command('DapRepeat',function() require('dap').run_last() end, {}) +vim.api.nvim_create_user_command('DapOpen',function() dapui.open() end, {}) +vim.api.nvim_create_user_command('DapClose',function() dapui.close() end, {}) |