From 259dbb7517000cc875a7a0f29426738cc762f342 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 30 Jan 2024 12:39:33 +0100 Subject: [PATCH] fix(lsp): only advertise `debugSingle` capability if nvim-dap is found --- CHANGELOG.md | 9 +++++++++ lua/rustaceanvim/lsp.lua | 18 +++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7350b341..a124346f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,17 @@ 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). +## [Unreleased] + +### Fixed + +- LSP: Only advertise `rust-analyzer.debugSingle` command capability + if nvim-dap is installed. + ## [4.2.0] - 2024-01-30 +### Added + - Config: Separate `tools.executor` and `tools.test_executor` options. The `test_executor` is used for test runnables (e.g. `cargo test`). - LSP: New test executor, `'background'` that runs tests in the background diff --git a/lua/rustaceanvim/lsp.lua b/lua/rustaceanvim/lsp.lua index 071306b6..f4eff85d 100644 --- a/lua/rustaceanvim/lsp.lua +++ b/lua/rustaceanvim/lsp.lua @@ -194,14 +194,18 @@ M.start = function(bufnr) } -- rust analyzer goodies + local experimental_commands = { + 'rust-analyzer.runSingle', + 'rust-analyzer.showReferences', + 'rust-analyzer.gotoLocation', + 'editor.action.triggerParameterHints', + } + if package.loaded['dap'] ~= nil then + table.insert(experimental_commands, 'rust-analyzer.debugSingle') + end + capabilities.experimental.commands = { - commands = { - 'rust-analyzer.runSingle', - 'rust-analyzer.debugSingle', - 'rust-analyzer.showReferences', - 'rust-analyzer.gotoLocation', - 'editor.action.triggerParameterHints', - }, + commands = experimental_commands, } lsp_start_config.capabilities = vim.tbl_deep_extend('force', capabilities, lsp_start_config.capabilities or {})