Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dap): use codelldb nvim-dap field when using codelldb #144

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.13.1] - 2024-01-10

### Fixed

- DAP: Use `codelldb` adapter nvim-dap field when using `codelldb`.

## [3.13.0] - 2024-01-09

### Added
Expand Down
18 changes: 12 additions & 6 deletions lua/rustaceanvim/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ local function get_lldb_commands(workspace_root)
end

---map for codelldb, list of strings for lldb-dap
---@param adapter DapExecutableConfig | DapServerConfig | boolean
---@param adapter DapExecutableConfig | DapServerConfig
---@param key string
---@param segments string[]
---@param sep string
Expand All @@ -176,7 +176,7 @@ end
local environments = {}

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

---@param adapter DapExecutableConfig | DapServerConfig | boolean
---@param adapter DapExecutableConfig | DapServerConfig
---@param args RADebuggableArgs
local function handle_configured_options(adapter, args)
local is_generate_source_map_enabled = types.evaluate(config.dap.auto_generate_source_map)
Expand All @@ -228,6 +228,10 @@ end
function M.start(args)
local adapter = types.evaluate(config.dap.adapter)
--- @cast adapter DapExecutableConfig | DapServerConfig | disable
if adapter == false then
vim.notify('Debug adapter is disabled.', vim.log.levels.ERROR)
return
end

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

-- If the `lldb` adapter is not defined elsewhere, use the adapter
-- If the adapter is not defined elsewhere, use the adapter
-- defined in `config.dap.adapter`
if dap.adapters.lldb == nil then
local is_codelldb = adapter.type == 'server'
local adapter_key = is_codelldb and 'codelldb' or 'lldb'
if dap.adapters[adapter_key] == nil then
---@TODO: Add nvim-dap to lua-ls lint
---@diagnostic disable-next-line: assign-type-mismatch
dap.adapters.lldb = adapter
dap.adapters[adapter_key] = adapter
end

-- Use the first configuration, if it exists
Expand Down