fix(rust): preserve loading of rust-analyzer.json #977
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📑 Description
merge astrolsp settings in such a way as to preserve the default behavior of loading local project settings from rust-analyzer.json
ℹ Additional Information
The default behavior of rustaceanvim is to load a
rust-analyzer.json
at the project root to load rust-anlyzer settingssee:
rustaceanvim/config/server.lua#L15
rustaceanvim/config/internal.lua#L287
this file can have any of the keys defined in https://rust-analyzer.github.io/manual.html#configuration
either at the top level of the json or under a
'rust-analyzer'
top level keyThis is done by having
server.settings
be a function that takes the project root path and the default settings configured atserver.default_settings
and calling rustaceanvim'srustaceanvim.config.server.load_rust_analyzer_settings(root, opts)
function.This change configures rustaceanvim by merging the astrolsp configured opts around a similar function that itself merges the astrolsp configured settings table with the defaults before loading the
rust-analyzer.json
as you can see, it's working as expected