From 5118c03f83a9276f3f77dca2e66ae17c6facd1cc Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sun, 12 Apr 2026 21:29:36 -0600 Subject: [PATCH] fix: python console output and startup breakpoint restoration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lua/turbo-debug/adapters/python.lua | 8 ++++++++ lua/turbo-debug/breakpoints.lua | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/lua/turbo-debug/adapters/python.lua b/lua/turbo-debug/adapters/python.lua index 61f1531..0e96786 100644 --- a/lua/turbo-debug/adapters/python.lua +++ b/lua/turbo-debug/adapters/python.lua @@ -36,6 +36,14 @@ function M.register(dap) 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 diff --git a/lua/turbo-debug/breakpoints.lua b/lua/turbo-debug/breakpoints.lua index a5ff7e0..4a3a86d 100644 --- a/lua/turbo-debug/breakpoints.lua +++ b/lua/turbo-debug/breakpoints.lua @@ -61,6 +61,16 @@ function M.setup() vim.fn.sign_define(s[1], spec) end + -- persistent-breakpoints.setup() only installs its BufReadPost autocmd — + -- for files opened from the command line (`nvim foo.py`), BufReadPost has + -- already fired before our deferred plugin/turbo-debug.lua setup runs, so + -- the autocmd misses the startup buffer and saved breakpoints never + -- reappear. load_breakpoints() iterates all listed buffers and is + -- idempotent, so one post-sign_define sweep catches the missed ones + -- without a flicker of dap's default 'B' sign. Placed after sign_define + -- so the restored breakpoints render with our emoji from the first paint. + pcall(require("persistent-breakpoints.api").load_breakpoints) + -- unobtrusive inline virtual text: italic, comment-colored vim.api.nvim_set_hl(0, "NvimDapVirtualText", { default = true, link = "Comment", italic = true }) vim.api.nvim_set_hl(0, "NvimDapVirtualTextChanged", { default = true, link = "DiagnosticWarn", italic = true })