implement range formatting

This commit is contained in:
Andy Russell
2021-05-04 17:13:51 -04:00
parent 1605488710
commit a90b9a5872
6 changed files with 167 additions and 102 deletions

View File

@@ -218,6 +218,10 @@ config_data! {
/// Advanced option, fully override the command rust-analyzer uses for
/// formatting.
rustfmt_overrideCommand: Option<Vec<String>> = "null",
/// Enables the use of rustfmt's unstable range formatting command for the
/// `textDocument/rangeFormatting` request. The rustfmt option is unstable and only
/// available on a nightly build.
rustfmt_enableRangeFormatting: bool = "false",
/// Workspace symbol search scope.
workspace_symbol_search_scope: WorskpaceSymbolSearchScopeDef = "\"workspace\"",
@@ -304,7 +308,7 @@ pub struct NotificationsConfig {
#[derive(Debug, Clone)]
pub enum RustfmtConfig {
Rustfmt { extra_args: Vec<String> },
Rustfmt { extra_args: Vec<String>, enable_range_formatting: bool },
CustomCommand { command: String, args: Vec<String> },
}
@@ -569,9 +573,10 @@ impl Config {
let command = args.remove(0);
RustfmtConfig::CustomCommand { command, args }
}
Some(_) | None => {
RustfmtConfig::Rustfmt { extra_args: self.data.rustfmt_extraArgs.clone() }
}
Some(_) | None => RustfmtConfig::Rustfmt {
extra_args: self.data.rustfmt_extraArgs.clone(),
enable_range_formatting: self.data.rustfmt_enableRangeFormatting,
},
}
}
pub fn flycheck(&self) -> Option<FlycheckConfig> {