made windows nvim debugging work better with vscode

This commit is contained in:
Mitchell Hingley committed 2026-09-08 15:53:56 -04:00
1 parent d2485ea96b
commit 66942a1daa
2 files changed
+25 -13

No files matched your search

+15 -11
View File
@@ -42,6 +42,7 @@ end
local function start_debug_session()
local is_windows = vim.fn.has("win32") == 1
local dap = require("dap")
-- 3. Platform-agnostic Launcher Configuration
if not is_windows then
@@ -57,9 +58,11 @@ local function start_debug_session()
},
}
else
local vscode = require('dap.ext.vscode')
local launch_json = vim.fn.getcwd() .. "/.vscode/launch.json"
if vim.fn.filereadable(launch_json) == 1 then
dap.configurations.cpp = {}
dap.configurations.c = {}
-- 1. CRUCIAL FIX: Alias the adapters directly so nvim-dap doesn't complain about a missing engine
--if dap.adapters.cppdbg then
-- dap.adapters.cppvsdbg = dap.adapters.cppdbg
@@ -67,11 +70,11 @@ local function start_debug_session()
-- dap.adapters.cppvsdbg = dap.adapters.codelldb
--end
-- 2. Map types inside launch.json to your C++ filetypes
vscode.load_launchjs(nil, {
vscode.type_to_filetypes = {
cppvsdbg = { "cpp", "c" },
cppdbg = { "cpp", "c" },
codelldb = { "cpp", "c" },
})
}
else
-- No launch.json exists. Re-inject your FZF picker template rules
dap.configurations.cpp = {
@@ -123,7 +126,7 @@ return {
-- Automatically manage debugger installations via Mason
require("mason-nvim-dap").setup({
ensure_installed = { "codelldb" }, -- Auto-installs CodeLLDB
ensure_installed = { "codelldb", "cppdbg" }, -- Auto-installs CodeLLDB
automatic_installation = true,
})
@@ -158,7 +161,7 @@ return {
executable = {
command = codelldb_path,
args = {"--port", "${port}"},
detached = not is_windows,
detached = false,
}
}
@@ -173,13 +176,13 @@ return {
}
dap.adapters.cppvsdbg = {
id = "cppdbg",
type = "executable",
command = cpptools_path,
-- For Windows subprocess tracking stability
options = {
detached = not is_windows,
},
type = 'server',
port = "${port}",
executable = {
command = codelldb_path,
args = {"--port", "${port}"},
detached = false,
}
}
-- 3. Platform-agnostic Launcher Configuration
@@ -225,3 +228,4 @@ return {
end
}