Skip to content

Commit e181a23

Browse files
committed
docs(dap): correct the loader and adapter comments
Name the user-override materialization as the second mason-nvim-dap load site, correct the upstream default_setup ipairs claim, and point the validate-order notes in every client back at the canonical contract in init.lua. delve: 38697 is the nvim-dap wiki's example port, not a delve default. lldb: the lldb-dap rename landed in LLVM 18, not 15. python: cover all raise sites and drop two boilerplate configuration comments.
1 parent 31f20ec commit e181a23

5 files changed

Lines changed: 28 additions & 25 deletions

File tree

lua/modules/configs/tool/dap/clients/codelldb.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ return function()
44
local utils = require("modules.utils.dap")
55
local is_windows = require("core.global").is_windows
66

7-
-- Self-validate at config time: launch AND attach both spawn the local binary, so
7+
-- Self-validate at config time (validate FIRST — contract: tool/dap/init.lua
8+
-- resolver spec): launch AND attach both spawn the local binary, so
89
-- unlike delve/python nothing is worth registering without it — error if missing.
910
local command =
1011
require("modules.utils.tools").exepath_or_error("codelldb", "install it via Mason or your package manager")

lua/modules/configs/tool/dap/clients/delve.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ return function()
1515
---@param config table
1616
local function delve_adapter(callback, config)
1717
if config.request == "attach" and config.mode == "remote" then
18-
-- Default when unset, but a malformed user port errors rather than silently
19-
-- falling back to delve's default 38697.
18+
-- Default when unset (38697 is the conventional example port from the
19+
-- nvim-dap wiki, not a delve default), but a malformed user port
20+
-- errors rather than silently falling back to it.
2021
local port = 38697
2122
if config.port ~= nil then
2223
local n = tonumber(config.port)

lua/modules/configs/tool/dap/clients/lldb.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ return function()
44
local utils = require("modules.utils.dap")
55

66
-- Opt-in preset (not in default dap_deps; codelldb covers C-family). Self-validate
7-
-- so the resolver surfaces `lldb`. LLVM 15 renamed `lldb-vscode` -> `lldb-dap`;
8-
-- probe the new name first, keep the old for distros still shipping it.
7+
-- so the resolver surfaces `lldb` (validate FIRST — contract:
8+
-- tool/dap/init.lua resolver spec). LLVM 18 renamed `lldb-vscode` ->
9+
-- `lldb-dap`; probe the new name first, keep the old for distros still
10+
-- shipping it.
911
local command = require("modules.utils.tools").exepath_or_error(
1012
{ "lldb-dap", "lldb-vscode" },
1113
"install it via your package manager (ships with LLVM/lldb)"

lua/modules/configs/tool/dap/clients/python.lua

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ return function()
5252
import_probe_retries = 0
5353
return command, args
5454
end
55-
-- One copy for both raise sites so the install guidance can't drift.
55+
-- One copy for all raise sites so the install guidance can't drift.
5656
local no_debugpy = "debugpy not found: no `debugpy-adapter` shim on $PATH or in Mason's bin dir,\n"
5757
.. "and no python able to import debugpy; install debugpy via Mason (`:Mason`)\n"
5858
.. "or your package manager"
@@ -159,11 +159,9 @@ return function()
159159
end
160160
dap.configurations.python = {
161161
{
162-
-- The first three options are required by nvim-dap
163-
type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python`
162+
type = "python", -- links to the adapter definition: `dap.adapters.python`
164163
request = "launch",
165164
name = "Debug",
166-
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
167165
console = "integratedTerminal",
168166
program = utils.input_file_path(),
169167
pythonPath = function()
@@ -176,11 +174,9 @@ return function()
176174
end,
177175
},
178176
{
179-
-- NOTE: This setting is for people using venv
180177
type = "python",
181178
request = "launch",
182179
name = "Debug (using venv)",
183-
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
184180
console = "integratedTerminal",
185181
program = utils.input_file_path(),
186182
pythonPath = function()

lua/modules/configs/tool/dap/init.lua

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ return function()
9696
vim.fn.sign_define("DapLogPoint", { text = icons.dap.LogPoint, texthl = "DapLogPoint", linehl = "", numhl = "" })
9797

9898
-- Everything Mason-flavored loads LAZILY: a session where every adapter
99-
-- self-validates from $PATH must not load mason.nvim / mason-nvim-dap on
100-
-- the :Dap* tick. First use (the factory fallback or a phase-2
101-
-- classification) goes through lazy.nvim's module loader; absence degrades
102-
-- to client-config/$PATH resolution as before.
99+
-- self-validates from $PATH — with no user overrides — must not load
100+
-- mason.nvim / mason-nvim-dap on the :Dap* tick. First use (the factory
101+
-- fallback, a phase-2 classification, or a user override's opts
102+
-- materialization) goes through lazy.nvim's module loader; absence
103+
-- degrades to client-config/$PATH resolution as before.
103104
local mason_dap = nil
104105
local function mason_dap_mod()
105106
if mason_dap == nil then
@@ -160,15 +161,16 @@ return function()
160161
end
161162

162163
---A handler to setup all clients defined under `tool/dap/clients/*.lua`.
163-
---Only the factory branch touches mason-nvim-dap: a client-config'd adapter
164-
---(every adapter in this repo) configures without loading Mason.
164+
---The factory branch and a user override's opts materialization load
165+
---mason-nvim-dap; a repo zero-arg client (every adapter in this repo)
166+
---configures without loading Mason.
165167
---@param dap_name string
166168
local function mason_dap_handler(dap_name)
167169
local custom_handler, broken_reason, _, user_won = load_client_config(dap_name)
168170
-- No-fall-through contract, enforced by the ONE shared implementation
169-
-- (tools.usable_or_raise, also used by mason_lsp_handler): a broken or
170-
-- wrong-shaped config must never read as success — that would suppress
171-
-- both the warning and the install fallback.
171+
-- (tools.usable_or_raise): a broken or wrong-shaped config must never
172+
-- read as success — that would suppress both the warning and the
173+
-- install fallback.
172174
custom_handler = tools.usable_or_raise(custom_handler, broken_reason, {
173175
label = "client config",
174176
expected = "a fun(opts)",
@@ -217,9 +219,10 @@ return function()
217219
)
218220
end
219221
-- Partial mappings drift can hand us configurations without
220-
-- filetypes (or vice versa); default_setup ipairs() both
221-
-- unconditionally. Degrade to whatever half is present instead of
222-
-- a raw ipairs(nil) raise.
222+
-- filetypes: upstream's default_setup guards configurations
223+
-- (`or {}`) but ipairs()es filetypes whenever configurations are
224+
-- non-empty — that combination raises ipairs(nil). Normalize both
225+
-- halves defensively.
223226
if type(config.configurations) ~= "table" then
224227
config.configurations = {}
225228
end
@@ -345,8 +348,8 @@ return function()
345348
-- install fallback — python resolves debugpy from a venv $PATH can't see.
346349
-- The raise on a missing launch binary is the provisioning signal.
347350
--
348-
-- CANONICAL availability contract for dap/clients/*.lua (referenced by the
349-
-- one-line notes in each client; keep the two patterns in sync here).
351+
-- CANONICAL availability contract for dap/clients/*.lua (the raise-LAST
352+
-- clients carry pointer notes back here; keep the two patterns in sync).
350353
-- Shape enforcement itself lives in tools.usable_or_raise; a
351354
-- metadata-declared contract ({ attach_capable, binaries }) was
352355
-- considered and rejected — it would churn the fun(opts) user-override

0 commit comments

Comments
 (0)