From f43a32433abdc954035ae7346272e25a29e17c79 Mon Sep 17 00:00:00 2001 From: Jatinderjit Singh Date: Mon, 21 Oct 2024 15:34:34 +0530 Subject: [PATCH 1/2] Replace rust-tools with rustaceanvim `rust-tools` is archived. The Astrocommunity Rust language pack has also moved to `rustaceanvim`. --- src/content/docs/recipes/advanced_lsp.mdx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/content/docs/recipes/advanced_lsp.mdx b/src/content/docs/recipes/advanced_lsp.mdx index 0843ac714..73ec52c30 100644 --- a/src/content/docs/recipes/advanced_lsp.mdx +++ b/src/content/docs/recipes/advanced_lsp.mdx @@ -566,7 +566,7 @@ return { } ``` -### Rust ([rust-tools.nvim](https://github.com/simrat39/rust-tools.nvim)) +### Rust ([rustaceanvim](https://github.com/mrcjkb/rustaceanvim)) :::tip @@ -581,19 +581,18 @@ return { ::: -```lua title="lua/plugins/rust-tools.lua" +```lua title="lua/plugins/rustaceanvim.lua" return { - { "simrat39/rust-tools.nvim", lazy = true }, -- add lsp plugin + { + 'mrcjkb/rustaceanvim', -- add lsp plugin + version = '^5', + lazy = false, -- This plugin is already lazy + }, { "AstroNvim/astrolsp", ---@type AstroLSPOpts opts = { - setup_handlers = { - -- add custom handler - rust_analyzer = function(_, opts) - require("rust-tools").setup({ server = opts }) - end, - }, + handlers = { rust_analyzer = false }, -- Let rustaceanvim setup `rust_analyzer` }, }, { From 866f683759559975733779db0c9a190cfb47db0b Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Sun, 19 Jan 2025 11:21:36 -0500 Subject: [PATCH 2/2] fix(rust): update rustaceanvim docs to use AstroLSP settings --- src/content/docs/recipes/advanced_lsp.mdx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/content/docs/recipes/advanced_lsp.mdx b/src/content/docs/recipes/advanced_lsp.mdx index 73ec52c30..09c6caf50 100644 --- a/src/content/docs/recipes/advanced_lsp.mdx +++ b/src/content/docs/recipes/advanced_lsp.mdx @@ -587,6 +587,28 @@ return { 'mrcjkb/rustaceanvim', -- add lsp plugin version = '^5', lazy = false, -- This plugin is already lazy + opts = function(_, opts) + local astrolsp_avail, astrolsp = pcall(require, "astrolsp") + local astrolsp_opts = (astrolsp_avail and astrolsp.lsp_opts "rust_analyzer") or {} + local server = { + ---@type table | (fun(project_root:string|nil, default_settings: table|nil):table) -- The rust-analyzer settings or a function that creates them. + settings = function(project_root, default_settings) + local astrolsp_settings = astrolsp_opts.settings or {} + + local merge_table = require("astrocore").extend_tbl(default_settings or {}, astrolsp_settings) + local ra = require "rustaceanvim.config.server" + -- load_rust_analyzer_settings merges any found settings with the passed in default settings table and then returns that table + return ra.load_rust_analyzer_settings(project_root, { + settings_file_pattern = "rust-analyzer.json", + default_settings = merge_table, + }) + end, + } + return { server = require("astrocore").extend_tbl(astrolsp_opts, server) } + end, + -- configure `rustaceanvim` by setting the `vim.g.rustaceanvim` variable + config = function(_, opts) vim.g.rustaceanvim = require("astrocore").extend_tbl(opts, vim.g.rustaceanvim) end, + }, { "AstroNvim/astrolsp",