@@ -587,6 +587,28 @@ return {
587587 ' mrcjkb/rustaceanvim' , -- add lsp plugin
588588 version = ' ^5' ,
589589 lazy = false , -- This plugin is already lazy
590+ opts = function (_ , opts )
591+ local astrolsp_avail , astrolsp = pcall (require , " astrolsp" )
592+ local astrolsp_opts = (astrolsp_avail and astrolsp .lsp_opts " rust_analyzer" ) or {}
593+ local server = {
594+ --- @type table | (fun ( project_root : string | nil , default_settings : table | nil ): table ) -- The rust-analyzer settings or a function that creates them.
595+ settings = function (project_root , default_settings )
596+ local astrolsp_settings = astrolsp_opts .settings or {}
597+
598+ local merge_table = require (" astrocore" ).extend_tbl (default_settings or {}, astrolsp_settings )
599+ local ra = require " rustaceanvim.config.server"
600+ -- load_rust_analyzer_settings merges any found settings with the passed in default settings table and then returns that table
601+ return ra .load_rust_analyzer_settings (project_root , {
602+ settings_file_pattern = " rust-analyzer.json" ,
603+ default_settings = merge_table ,
604+ })
605+ end ,
606+ }
607+ return { server = require (" astrocore" ).extend_tbl (astrolsp_opts , server ) }
608+ end ,
609+ -- configure `rustaceanvim` by setting the `vim.g.rustaceanvim` variable
610+ config = function (_ , opts ) vim .g .rustaceanvim = require (" astrocore" ).extend_tbl (opts , vim .g .rustaceanvim ) end ,
611+
590612 },
591613 {
592614 " AstroNvim/astrolsp" ,
0 commit comments