Mechanical cleanup pass, behavior-preserving: - remove dead code: reposition_bars (unused), sbar click infrastructure (zones never populated, handler iterated empty list) - extract helpers in mode.lua: win_ok, buf_ok, is_dapui_pane_ft, for_each_dapui_pane (asymmetric filter preserved), safe_extmark, bar_set_lines, safe_set_height, if_still_active, invalidate_dead_bars, focus_source_win, unset_and_restore - inline install_cs_listener inside define_highlights to dedup the three ColorScheme augroup+autocmd triples (italic, key, sep) - data-drive sign_define in breakpoints.lua - data-drive python interpreter candidate probing - add tests/test_render_bars.lua pinning sbar/cbar output dimensions, zones, and overflow fallback behavior - add tests/test_highlights_cs.lua verifying ColorScheme augroups and highlight group existence / re-apply on event - add tests/test_helpers.lua unit-testing keyof and source_window - expose M._test (direct function refs) so render/highlight internals are testable in headless mode
44 lines
1.3 KiB
Lua
44 lines
1.3 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,
|
|
},
|
|
}, { "python" })
|
|
end
|
|
|
|
return M
|