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): ensure codelldb client type when using codelldb adapter #141

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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- DAP: Don't load `lldb_commands` when using `codelldb`.
- DAP: Make sure the client configuration type is 'codelldb'
when using a 'codelldb' adapter.

## [3.12.2] - 2024-01-07

Expand Down
24 changes: 21 additions & 3 deletions lua/rustaceanvim/config/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ local function should_enable_dap_config_value(dap_adapter)
return vim.fn.executable('rustc') == 1
end

---@param adapter DapServerConfig | DapExecutableConfig
local function is_codelldb_adapter(adapter)
return adapter.type == 'server'
end

---@param adapter DapServerConfig | DapExecutableConfig
local function is_lldb_adapter(adapter)
return adapter.type == 'executable'
end

---@class RustaceanConfig
local RustaceanDefaultConfig = {
---@class RustaceanToolsConfig
Expand Down Expand Up @@ -274,8 +284,8 @@ local RustaceanDefaultConfig = {
return false
end
local adapter = types.evaluate(RustaceanConfig.dap.adapter)
--- @cast adapter DapExecutableConfig | DapServerConfig | disable
return adapter ~= false and adapter.type == 'executable'
---@cast adapter DapExecutableConfig | DapServerConfig | disable
return adapter ~= false and is_lldb_adapter(adapter)
end,
--- @type DapClientConfig | disable | fun():(DapClientConfig | disable)
configuration = function()
Expand All @@ -284,11 +294,19 @@ local RustaceanDefaultConfig = {
return false
end

local adapter = types.evaluate(RustaceanConfig.dap.adapter)
---@cast adapter DapExecutableConfig | DapServerConfig | disable
if adapter == false then
return false
end
---@cast adapter DapExecutableConfig | DapServerConfig
local type = is_codelldb_adapter(adapter) and 'codelldb' or 'lldb'

-- default
---@type DapClientConfig
local dap_config = {
name = 'Rust debug client',
type = 'lldb',
type = type,
request = 'launch',
stopOnEntry = false,
}
Expand Down