diff options
| author | Kyren223 <ulmliad223@gmail.com> | 2024-08-06 17:27:17 +0300 |
|---|---|---|
| committer | Kyren223 <ulmliad223@gmail.com> | 2024-08-06 17:27:17 +0300 |
| commit | 53218a7c0e322a24abdd1f2c5c66fb558fc46675 (patch) | |
| tree | 60957118e0bdfbe14de881b0601dc19c8d122572 /.config/nvim/lua/custom | |
| parent | 46335ce5edb504e1653e140e037f15be104e81db (diff) | |
feat(nvim): added nvim-dap plugin with integration for codelldb (C/C++)
Diffstat (limited to '.config/nvim/lua/custom')
| -rw-r--r-- | .config/nvim/lua/custom/plugins/nvim-dap.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/.config/nvim/lua/custom/plugins/nvim-dap.lua b/.config/nvim/lua/custom/plugins/nvim-dap.lua new file mode 100644 index 0000000..0dd44c5 --- /dev/null +++ b/.config/nvim/lua/custom/plugins/nvim-dap.lua @@ -0,0 +1,46 @@ +return { + 'mfussenegger/nvim-dap', + dependencies = { 'williamboman/mason.nvim' }, + opts = function() + local dap = require('dap') + + -- Setup C/C++ dap + if not dap.adapters['codelldb'] then + dap.adapters['codelldb'] = { + type = 'server', + host = 'localhost', + port = '${port}', + executable = { + command = 'codelldb', + args = { + '--port', + '${port}', + }, + }, + } + end + for _, lang in ipairs({ 'c', 'cpp' }) do + dap.configurations[lang] = { + { + type = 'codelldb', + request = 'launch', + name = 'Launch file', + program = function() + if vim.g.dap_codelldb_exe then + return vim.fn.getcwd() .. '/' .. vim.g.dap_codelldb_exe + end + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + }, + { + type = 'codelldb', + request = 'attach', + name = 'Attach to process', + pid = require('dap.utils').pick_process, + cwd = '${workspaceFolder}', + }, + } + end + end, +} |
