Skip to content

Commit 207f284

Browse files
authored
fix(dap): use codelldb nvim-dap field when using codelldb (#144)
1 parent c8856f9 commit 207f284

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.
66
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [3.13.1] - 2024-01-10
10+
11+
### Fixed
12+
13+
- DAP: Use `codelldb` adapter nvim-dap field when using `codelldb`.
14+
915
## [3.13.0] - 2024-01-09
1016

1117
### Added

lua/rustaceanvim/dap.lua

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ local function get_lldb_commands(workspace_root)
157157
end
158158

159159
---map for codelldb, list of strings for lldb-dap
160-
---@param adapter DapExecutableConfig | DapServerConfig | boolean
160+
---@param adapter DapExecutableConfig | DapServerConfig
161161
---@param key string
162162
---@param segments string[]
163163
---@param sep string
@@ -176,7 +176,7 @@ end
176176
local environments = {}
177177

178178
-- Most succinct description: https://github.com/bevyengine/bevy/issues/2589#issuecomment-1753413600
179-
---@param adapter DapExecutableConfig | DapServerConfig | boolean
179+
---@param adapter DapExecutableConfig | DapServerConfig
180180
---@param workspace_root string
181181
local function add_dynamic_library_paths(adapter, workspace_root)
182182
compat.system({ 'rustc', '--print', 'target-libdir' }, nil, function(sc)
@@ -202,7 +202,7 @@ local function add_dynamic_library_paths(adapter, workspace_root)
202202
end)
203203
end
204204

205-
---@param adapter DapExecutableConfig | DapServerConfig | boolean
205+
---@param adapter DapExecutableConfig | DapServerConfig
206206
---@param args RADebuggableArgs
207207
local function handle_configured_options(adapter, args)
208208
local is_generate_source_map_enabled = types.evaluate(config.dap.auto_generate_source_map)
@@ -228,6 +228,10 @@ end
228228
function M.start(args)
229229
local adapter = types.evaluate(config.dap.adapter)
230230
--- @cast adapter DapExecutableConfig | DapServerConfig | disable
231+
if adapter == false then
232+
vim.notify('Debug adapter is disabled.', vim.log.levels.ERROR)
233+
return
234+
end
231235

232236
vim.notify('Compiling a debug build for debugging. This might take some time...')
233237
handle_configured_options(adapter, args)
@@ -282,12 +286,14 @@ function M.start(args)
282286
return
283287
end
284288

285-
-- If the `lldb` adapter is not defined elsewhere, use the adapter
289+
-- If the adapter is not defined elsewhere, use the adapter
286290
-- defined in `config.dap.adapter`
287-
if dap.adapters.lldb == nil then
291+
local is_codelldb = adapter.type == 'server'
292+
local adapter_key = is_codelldb and 'codelldb' or 'lldb'
293+
if dap.adapters[adapter_key] == nil then
288294
---@TODO: Add nvim-dap to lua-ls lint
289295
---@diagnostic disable-next-line: assign-type-mismatch
290-
dap.adapters.lldb = adapter
296+
dap.adapters[adapter_key] = adapter
291297
end
292298

293299
-- Use the first configuration, if it exists

0 commit comments

Comments
 (0)