Files
swaits 5118c03f83 fix: python console output and startup breakpoint restoration
adapters/python: set `console = "integratedTerminal"` so debugpy routes stdout/stderr via RunInTerminalRequest into dapui's Console pane. Under the default (internalConsole), debugpy emits DAP OutputEvents that nvim-dap forwards to the REPL buffer — which turbo-debug's layout deliberately omits, so print() output vanished.

breakpoints: sweep already-loaded buffers with load_breakpoints() right after sign_define. plugin/turbo-debug.lua defers setup via vim.schedule so deps register first, which means BufReadPost has already fired for any file opened on the command line — persistent-breakpoints' autocmd misses it. The one-shot sweep is idempotent; placing it after sign_define avoids a first-paint flicker of dap's default 'B' sign.
2026-04-12 21:35:50 -06:00

52 lines
1.8 KiB
Lua

local loader = require("turbo-debug.adapters.init")
local M = {}
-- Try in order: active virtualenv, conda, common local venv dirs, system.
-- First executable match wins. Using a single ordered list keeps the probe
-- sequence explicit (ipairs preserves numeric order).
local function find_python()
local candidates = {}
if vim.env.VIRTUAL_ENV then candidates[#candidates + 1] = vim.env.VIRTUAL_ENV .. "/bin/python" end
if vim.env.CONDA_PREFIX then candidates[#candidates + 1] = vim.env.CONDA_PREFIX .. "/bin/python" end
local cwd = vim.fn.getcwd()
for _, dir in ipairs({ ".venv", "venv", "env", ".env" }) do
candidates[#candidates + 1] = cwd .. "/" .. dir .. "/bin/python"
end
candidates[#candidates + 1] = "python3"
candidates[#candidates + 1] = "python"
for _, p in ipairs(candidates) do
if vim.fn.executable(p) == 1 then return p end
end
return nil
end
function M.register(dap)
local python = find_python()
if not python then return end
loader.register(dap, "debugpy", {
type = "executable",
command = python,
args = { "-m", "debugpy.adapter" },
}, {
{
type = "debugpy",
request = "launch",
name = "Launch file",
program = "${file}",
pythonPath = function() return find_python() end,
-- integratedTerminal routes the program via RunInTerminalRequest,
-- which nvim-dap spawns in a terminal buffer. dapui registers its
-- Console element as `dap.defaults.fallback.terminal_win_cmd`, so
-- stdout/stderr land in the visible Console pane. Default
-- (internalConsole) sends OutputEvents that nvim-dap routes to the
-- REPL buffer — which turbo-debug's layout deliberately omits, so
-- print() output vanishes. `input()` also works under this mode.
console = "integratedTerminal",
},
}, { "python" })
end
return M