From 61ca8b71d026b2c0e0511ed6a2e8ba099fa2efe3 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 9 Jan 2024 10:37:00 +0100 Subject: [PATCH] fix(dap): ensure `codelldb` client type when using `codelldb` adapter (#141) --- CHANGELOG.md | 2 ++ lua/rustaceanvim/config/internal.lua | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 356cd653..4acc525c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index 348f8c12..48d02b65 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -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 @@ -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() @@ -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, }