refactor: extract helpers, dedup patterns, add regression tests
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
This commit is contained in:
7 files changed
+414
-164
No files matched your search
@@ -2,31 +2,22 @@ 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()
|
||||
-- check active virtualenv
|
||||
local venv = vim.env.VIRTUAL_ENV
|
||||
if venv then
|
||||
local path = venv .. "/bin/python"
|
||||
if vim.fn.executable(path) == 1 then return path end
|
||||
end
|
||||
|
||||
-- check conda
|
||||
local conda = vim.env.CONDA_PREFIX
|
||||
if conda then
|
||||
local path = conda .. "/bin/python"
|
||||
if vim.fn.executable(path) == 1 then return path end
|
||||
end
|
||||
|
||||
-- probe common venv directories relative to cwd
|
||||
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
|
||||
local path = cwd .. "/" .. dir .. "/bin/python"
|
||||
if vim.fn.executable(path) == 1 then return path end
|
||||
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
|
||||
|
||||
-- fallback to system python
|
||||
if vim.fn.executable("python3") == 1 then return "python3" end
|
||||
if vim.fn.executable("python") == 1 then return "python" end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user