Rename from tiny-debugger to turbo-debug — inspired by Turbo Pascal, the first IDE with a real visual debugger. This thing isn't tiny, it's turbo charged. CHANGELOG for 0.1.0: Features: - Zero-config debugging — one line install, everything works - Modal keybindings (c/s/d/r/q/x/X/D/W/K/E/R/?), active only during debug mode, cleanly removed on exit - Persistent breakpoints via persistent-breakpoints.nvim - Inline virtual text — variable values in source code - Hover (K), watch (W), REPL eval (E) from the code window - Help splash (3s auto-dismiss) + manual help (?) - Debug mode chrome — winbar indicator, cursor highlight - dapui integration — controls toolbar, labeled panels - which-key support — <leader>d debug group auto-registered - quit_exits_mode option Adapters (12 languages): - Python (debugpy + venv detection) - Rust (codelldb + cargo build + vim.ui.select picker) - Go (delve), C/C++/Swift (codelldb) - JavaScript/TypeScript (js-debug-adapter) - C# (netcoredbg), Java, Kotlin, PHP, Ruby, Lua (osv) Keybindings: - <leader>dd — toggle debug mode - <leader>dx / <leader>dX / <leader>dD — breakpoints (always) - c s d r C x X D W K E q R ? — modal (debug mode only)
90 lines
2.3 KiB
Lua
90 lines
2.3 KiB
Lua
local loader = require("turbo-debug.adapters.init")
|
|
|
|
local M = {}
|
|
|
|
local function pick_executable(executables)
|
|
local co = coroutine.running()
|
|
if not co then
|
|
return executables[1]
|
|
end
|
|
vim.ui.select(executables, {
|
|
prompt = "Select executable",
|
|
format_item = function(path) return vim.fn.fnamemodify(path, ":t") end,
|
|
}, function(choice)
|
|
coroutine.resume(co, choice)
|
|
end)
|
|
return coroutine.yield()
|
|
end
|
|
|
|
local function cargo_build_and_pick()
|
|
vim.notify("cargo build ...")
|
|
local output = vim.fn.system("cargo build --message-format=json")
|
|
if vim.v.shell_error ~= 0 then
|
|
local errors = {}
|
|
for line in output:gmatch("[^\n]+") do
|
|
if not line:match("^{") then errors[#errors + 1] = line end
|
|
end
|
|
vim.notify("cargo build failed:\n" .. table.concat(errors, "\n"), vim.log.levels.ERROR)
|
|
return nil
|
|
end
|
|
|
|
local executables = {}
|
|
for line in output:gmatch("[^\n]+") do
|
|
local ok, msg = pcall(vim.json.decode, line)
|
|
if ok and msg.reason == "compiler-artifact" and msg.executable then
|
|
executables[#executables + 1] = msg.executable
|
|
end
|
|
end
|
|
|
|
if #executables == 0 then return nil end
|
|
if #executables == 1 then return executables[1] end
|
|
return pick_executable(executables)
|
|
end
|
|
|
|
function M.register(dap)
|
|
local codelldb = loader.find_executable({ "codelldb" })
|
|
if not codelldb then return end
|
|
|
|
local adapter = {
|
|
type = "server",
|
|
port = "${port}",
|
|
executable = {
|
|
command = codelldb,
|
|
args = { "--port", "${port}" },
|
|
},
|
|
}
|
|
|
|
if not dap.adapters.codelldb then
|
|
dap.adapters.codelldb = adapter
|
|
end
|
|
|
|
-- C/C++/Swift: pick from compiled executables in cwd
|
|
local prompt_config = {
|
|
{
|
|
type = "codelldb",
|
|
request = "launch",
|
|
name = "Launch executable",
|
|
program = function()
|
|
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
|
end,
|
|
cwd = "${workspaceFolder}",
|
|
},
|
|
}
|
|
for _, ft in ipairs({ "c", "cpp", "swift" }) do
|
|
dap.configurations[ft] = dap.configurations[ft] or prompt_config
|
|
end
|
|
|
|
-- Rust: cargo build + picker
|
|
dap.configurations.rust = dap.configurations.rust or {
|
|
{
|
|
type = "codelldb",
|
|
request = "launch",
|
|
name = "Cargo build & launch",
|
|
program = cargo_build_and_pick,
|
|
cwd = "${workspaceFolder}",
|
|
},
|
|
}
|
|
end
|
|
|
|
return M
|