Parameter inlay hint separate from variable type inlay? #2876

Add setting to allow enabling either type inlay hints or parameter
inlay hints or both. Group the the max inlay hint length option
into the object.

- Add a new type for the inlayHint options.
- Add tests to ensure the inlays don't happen on the server side
This commit is contained in:
Steffen Lyngbaek 2020-03-10 00:55:46 -07:00
parent 0714a065d5
commit e98aff109a
13 changed files with 155 additions and 34 deletions

View file

@ -7,6 +7,7 @@
//! configure the server itself, feature flags are passed into analysis, and
//! tweak things like automatic insertion of `()` in completions.
use ra_project_model::InlayHintOptions;
use rustc_hash::FxHashMap;
use ra_project_model::CargoFeatures;
@ -30,7 +31,7 @@ pub struct ServerConfig {
pub lru_capacity: Option<usize>,
pub max_inlay_hint_length: Option<usize>,
pub inlay_hint_opts: InlayHintOptions,
pub cargo_watch_enable: bool,
pub cargo_watch_args: Vec<String>,
@ -57,7 +58,7 @@ impl Default for ServerConfig {
exclude_globs: Vec::new(),
use_client_watching: false,
lru_capacity: None,
max_inlay_hint_length: None,
inlay_hint_opts: Default::default(),
cargo_watch_enable: true,
cargo_watch_args: Vec::new(),
cargo_watch_command: "check".to_string(),

View file

@ -177,7 +177,7 @@ pub fn main_loop(
.and_then(|it| it.folding_range.as_ref())
.and_then(|it| it.line_folding_only)
.unwrap_or(false),
max_inlay_hint_length: config.max_inlay_hint_length,
inlay_hint_opts: config.inlay_hint_opts.clone(),
cargo_watch: CheckOptions {
enable: config.cargo_watch_enable,
args: config.cargo_watch_args,

View file

@ -15,7 +15,7 @@ use ra_cargo_watch::{url_from_path_with_drive_lowercasing, CheckOptions, CheckWa
use ra_ide::{
Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, SourceRootId,
};
use ra_project_model::{get_rustc_cfg_options, ProjectWorkspace};
use ra_project_model::{get_rustc_cfg_options, InlayHintOptions, ProjectWorkspace};
use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot, VfsTask, Watch};
use relative_path::RelativePathBuf;
@ -32,7 +32,7 @@ pub struct Options {
pub publish_decorations: bool,
pub supports_location_link: bool,
pub line_folding_only: bool,
pub max_inlay_hint_length: Option<usize>,
pub inlay_hint_opts: InlayHintOptions,
pub rustfmt_args: Vec<String>,
pub cargo_watch: CheckOptions,
}