jiriks74
db5a3f56b4
Added: - OpenDebugAD7 from [vscode-cpptools](https://github.com/microsoft/vscode-cpptools) It works better with `nvim-dap-ui`. With GDB you have to wait for stdout flush to see program output, the output is in the repl instead of the console, etc. The VSCode debugger doesn't have such issues.
72 lines
1.9 KiB
Lua
72 lines
1.9 KiB
Lua
-- Exit if the language server isn't available
|
|
if vim.fn.executable('clangd') ~= 1 then
|
|
return
|
|
end
|
|
|
|
-- require'lspconfig'.clangd.setup{}
|
|
|
|
local root_files = {
|
|
'compile_commands.json',
|
|
'.vscode',
|
|
'.git',
|
|
}
|
|
|
|
vim.lsp.start {
|
|
name = 'clangd',
|
|
cmd = { 'clangd' },
|
|
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
|
|
capabilities = require('user.lsp').make_client_capabilities(),
|
|
}
|
|
|
|
local dap = require("dap")
|
|
local pickers = require("telescope.pickers")
|
|
local finders = require("telescope.finders")
|
|
local conf = require("telescope.config").values
|
|
local actions = require("telescope.actions")
|
|
local action_state = require("telescope.actions.state")
|
|
|
|
if require('user.file_exists').file_exists(vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]) .. "/.vscode/launch.json") then
|
|
require("dap.ext.vscode").load_launchjs(nil, { cppdbg = { "c", "cpp", "asm" } })
|
|
end
|
|
|
|
dap.adapters.gdb = {
|
|
type = "executable",
|
|
command = "gdb",
|
|
args = { "-i", "dap" }
|
|
}
|
|
|
|
dap.adapters.cppdbg = {
|
|
id = 'cppdbg',
|
|
type = 'executable',
|
|
command = 'OpenDebugAD7',
|
|
}
|
|
|
|
dap.configurations.c = {
|
|
{
|
|
name = "Launch an executable",
|
|
type = "cppdbg",
|
|
request = "launch",
|
|
cwd = "${workspaceFolder}",
|
|
program = function()
|
|
return coroutine.create(function(coro)
|
|
local opts = {}
|
|
pickers
|
|
.new(opts, {
|
|
prompt_title = "Path to executable",
|
|
finder = finders.new_oneshot_job({ "fd", "--hidden", "--no-ignore", "--type", "x" }, {}),
|
|
sorter = conf.generic_sorter(opts),
|
|
attach_mappings = function(buffer_number)
|
|
actions.select_default:replace(function()
|
|
actions.close(buffer_number)
|
|
coroutine.resume(coro, action_state.get_selected_entry()[1])
|
|
end)
|
|
return true
|
|
end,
|
|
})
|
|
:find()
|
|
end)
|
|
end,
|
|
stopAtBeginningOfMainSubprogram = true,
|
|
},
|
|
}
|