From 73b53d408a8795d3da3a668a394ca5b2875d0db4 Mon Sep 17 00:00:00 2001 From: Patrick Auernig Date: Sun, 11 Feb 2024 21:32:21 +0100 Subject: [PATCH] Update rust-analyzer config --- lua/valeth/plugins/lsp.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lua/valeth/plugins/lsp.lua b/lua/valeth/plugins/lsp.lua index 96c05df..a884d7f 100644 --- a/lua/valeth/plugins/lsp.lua +++ b/lua/valeth/plugins/lsp.lua @@ -65,17 +65,22 @@ spec.config = function() } }) + local rust_analyzer_settings = { + cargo = { + features = "all" + }, + } + + -- Don't have rustup available if using nix shell + if vim.fn.executable("rustup") == 1 then + rust_analyzer_settings = vim.tbl_extend("keep", rust_analyzer_settings, { + rustfmt = { extraArgs = { "+nightly" } } + }) + end + lsp_config.rust_analyzer.setup({ settings = { - ["rust-analyzer"] = { - cargo = { - features = "all" - }, - rustfmt = { - -- needs to use nightly channel to use unstable options - extraArgs = { "+nightly" } - } - } + ["rust-analyzer"] = rust_analyzer_settings } })