From d263e145f432b6c56320ad90a80e2bd8fd7d6ca9 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Tue, 22 Dec 2020 18:33:13 -0800 Subject: Rust-analyzer: fix for missing required capabilities * set normalizesLineEndings and changeAnnotationSupport.groupsOnLabel = true to work around rust-analyzer incompatibilities --- lua/lspconfig/rust_analyzer.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lspconfig/rust_analyzer.lua b/lua/lspconfig/rust_analyzer.lua index 2d545517..12bcfbae 100644 --- a/lua/lspconfig/rust_analyzer.lua +++ b/lua/lspconfig/rust_analyzer.lua @@ -1,6 +1,17 @@ local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' +-- neovim doesn't support the full 3.16 spec, but latest rust-analyzer requires the following capabilities. +-- Remove once implemented. +local default_capabilities = vim.lsp.protocol.make_client_capabilities() +default_capabilities.workspace.workspaceEdit = { + normalizesLineEndings = true; + changeAnnotationSupport = { + groupsOnLabel = true; + }; +}; +default_capabilities.textDocument.rename.prepareSupportDefaultBehavior = 1; + configs.rust_analyzer = { default_config = { cmd = {"rust-analyzer"}; @@ -8,7 +19,8 @@ configs.rust_analyzer = { root_dir = util.root_pattern("Cargo.toml", "rust-project.json"); settings = { ["rust-analyzer"] = {} - } + }; + capabilities = default_capabilities; }; docs = { package_json = "https://raw.githubusercontent.com/rust-analyzer/rust-analyzer/master/editors/code/package.json"; -- cgit v1.2.3-70-g09d2