From 53218a7c0e322a24abdd1f2c5c66fb558fc46675 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Tue, 6 Aug 2024 17:27:17 +0300 Subject: feat(nvim): added nvim-dap plugin with integration for codelldb (C/C++) --- .config/nvim/lazy-lock.json | 1 + .config/nvim/lua/custom/plugins/nvim-dap.lua | 46 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .config/nvim/lua/custom/plugins/nvim-dap.lua diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index bab182e..720b105 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -35,6 +35,7 @@ "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, "nvim-autopairs": { "branch": "master", "commit": "e38c5d837e755ce186ae51d2c48e1b387c4425c6" }, "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-dap": { "branch": "master", "commit": "dcc85d12d6e2c18c5fa0f9a304d9f5e767e1401a" }, "nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" }, "nvim-lsp-file-operations": { "branch": "master", "commit": "92a673de7ecaa157dd230d0128def10beb56d103" }, "nvim-lspconfig": { "branch": "master", "commit": "e6528f4613c8db2e04be908eb2b5886d63f62a98" }, 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, +} -- cgit v1.3.1