diff --git a/CHANGELOG.md b/CHANGELOG.md index 19019793..5381e40c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ 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.16.1] - 2024-01-17 + +### Fixed + +- DAP: Improve reliability of loading Rust debug configurations on LSP attach. +- DAP: Assign `lldb` and `codelldb` configurations found in `launch.json` + to `dap.configurations.rust`. + ## [3.16.0] - 2024-01-15 ### Added diff --git a/README.md b/README.md index d05fe25b..7e9a4059 100644 --- a/README.md +++ b/README.md @@ -169,13 +169,17 @@ vim.keymap.set( vim.cmd.RustLsp {'debuggables', 'last' --[[ optional ]] } ``` - > [!NOTE] - > - > By default, this plugin will silently attempt to autoload `nvim-dap` - > configurations when the LSP client attaches. - > You can call them with `require('dap').continue()` once - > they have been loaded. The feature can be disabled by setting - > `vim.g.rustaceanvim.dap.autoload_configurations = false`. + By default, this plugin will silently attempt to autoload `nvim-dap` + configurations when the LSP client attaches. + You can call them with `require('dap').continue()` once + they have been loaded. The feature can be disabled by setting + `vim.g.rustaceanvim.dap.autoload_configurations = false`. + + - `:RustLsp debuggables` will only load debug configurations + created by `rust-analyzer`. + - `require('dap').continue()` will load all Rust debug configurations, + including those specified in a `.vscode/launch.json` + (see [`:h dap-launch.json`](https://github.com/mfussenegger/nvim-dap/blob/9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5/doc/dap.txt#L316)). ![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/ce17d228-ae0a-416a-8159-fe095a85dcb7) diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index c52ad47e..377d8430 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -319,7 +319,7 @@ local RustaceanDefaultConfig = { -- It is necessary to check for changes in the `dap.configurations` table, as -- `load_launchjs` does not return anything, it loads directly into `dap.configurations`. local pre_launch = vim.deepcopy(dap.configurations) or {} - require('dap.ext.vscode').load_launchjs() + require('dap.ext.vscode').load_launchjs(nil, { lldb = { 'rust' }, codelldb = { 'rust' } }) for k, v in pairs(dap.configurations) do if pre_launch[k] == nil or not vim.deep_equal(pre_launch[k], v) then -- `configurations` are tables of `configuration` entries diff --git a/lua/rustaceanvim/lsp.lua b/lua/rustaceanvim/lsp.lua index 0cb17bd7..93d649a5 100644 --- a/lua/rustaceanvim/lsp.lua +++ b/lua/rustaceanvim/lsp.lua @@ -218,12 +218,12 @@ M.start = function(bufnr) local old_on_attach = lsp_start_opts.on_attach lsp_start_opts.on_attach = function(...) - if config.dap.autoload_configurations then - require('rustaceanvim.commands.debuggables').add_dap_debuggables() - end if type(old_on_attach) == 'function' then old_on_attach(...) end + if config.dap.autoload_configurations then + require('rustaceanvim.commands.debuggables').add_dap_debuggables() + end end local old_on_exit = lsp_start_opts.on_exit diff --git a/lua/rustaceanvim/server_status.lua b/lua/rustaceanvim/server_status.lua index 4b44da61..ef4bee8b 100644 --- a/lua/rustaceanvim/server_status.lua +++ b/lua/rustaceanvim/server_status.lua @@ -28,6 +28,9 @@ function M.handler(_, result, ctx, _) if config.tools.on_initialized then config.tools.on_initialized(result) end + if config.dap.autoload_configurations then + require('rustaceanvim.commands.debuggables').add_dap_debuggables() + end _ran_once[ctx.client_id] = true end