Keep VSCode config mostly backwards compatible
This commit is contained in:
parent
71d2d81dcc
commit
0cdbd08149
8 changed files with 71 additions and 84 deletions
|
|
@ -39,22 +39,14 @@ pub struct CheckWatcher {
|
|||
|
||||
impl CheckWatcher {
|
||||
pub fn new(options: &Options, workspace_root: PathBuf) -> CheckWatcher {
|
||||
let check_enabled = options.cargo_check_enable;
|
||||
let check_command = options.cargo_check_command.clone();
|
||||
let check_args = options.cargo_check_args.clone();
|
||||
let options = options.clone();
|
||||
let shared = Arc::new(RwLock::new(CheckWatcherSharedState::new()));
|
||||
|
||||
let (task_send, task_recv) = unbounded::<CheckTask>();
|
||||
let (cmd_send, cmd_recv) = unbounded::<CheckCommand>();
|
||||
let shared_ = shared.clone();
|
||||
let handle = std::thread::spawn(move || {
|
||||
let mut check = CheckWatcherState::new(
|
||||
check_enabled,
|
||||
check_command,
|
||||
check_args,
|
||||
workspace_root,
|
||||
shared_,
|
||||
);
|
||||
let mut check = CheckWatcherState::new(options, workspace_root, shared_);
|
||||
check.run(&task_send, &cmd_recv);
|
||||
});
|
||||
|
||||
|
|
@ -68,9 +60,7 @@ impl CheckWatcher {
|
|||
}
|
||||
|
||||
pub struct CheckWatcherState {
|
||||
check_enabled: bool,
|
||||
check_command: Option<String>,
|
||||
check_args: Vec<String>,
|
||||
options: Options,
|
||||
workspace_root: PathBuf,
|
||||
running: bool,
|
||||
watcher: WatchThread,
|
||||
|
|
@ -162,18 +152,13 @@ pub enum CheckCommand {
|
|||
|
||||
impl CheckWatcherState {
|
||||
pub fn new(
|
||||
check_enabled: bool,
|
||||
check_command: Option<String>,
|
||||
check_args: Vec<String>,
|
||||
options: Options,
|
||||
workspace_root: PathBuf,
|
||||
shared: Arc<RwLock<CheckWatcherSharedState>>,
|
||||
) -> CheckWatcherState {
|
||||
let watcher =
|
||||
WatchThread::new(check_enabled, check_command.as_ref(), &check_args, &workspace_root);
|
||||
let watcher = WatchThread::new(&options, &workspace_root);
|
||||
CheckWatcherState {
|
||||
check_enabled,
|
||||
check_command,
|
||||
check_args,
|
||||
options,
|
||||
workspace_root,
|
||||
running: false,
|
||||
watcher,
|
||||
|
|
@ -204,12 +189,7 @@ impl CheckWatcherState {
|
|||
self.shared.write().clear(task_send);
|
||||
|
||||
self.watcher.cancel();
|
||||
self.watcher = WatchThread::new(
|
||||
self.check_enabled,
|
||||
self.check_command.as_ref(),
|
||||
&self.check_args,
|
||||
&self.workspace_root,
|
||||
);
|
||||
self.watcher = WatchThread::new(&self.options, &self.workspace_root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -306,25 +286,23 @@ enum CheckEvent {
|
|||
}
|
||||
|
||||
impl WatchThread {
|
||||
fn new(
|
||||
check_enabled: bool,
|
||||
check_command: Option<&String>,
|
||||
check_args: &[String],
|
||||
workspace_root: &PathBuf,
|
||||
) -> WatchThread {
|
||||
let check_command = check_command.cloned().unwrap_or("check".to_string());
|
||||
fn new(options: &Options, workspace_root: &PathBuf) -> WatchThread {
|
||||
let mut args: Vec<String> = vec![
|
||||
check_command,
|
||||
options.cargo_watch_command.clone(),
|
||||
"--message-format=json".to_string(),
|
||||
"--manifest-path".to_string(),
|
||||
format!("{}/Cargo.toml", workspace_root.to_string_lossy()),
|
||||
];
|
||||
args.extend(check_args.iter().cloned());
|
||||
if options.cargo_watch_all_targets {
|
||||
args.push("--all-targets".to_string());
|
||||
}
|
||||
args.extend(options.cargo_watch_args.iter().cloned());
|
||||
|
||||
let (message_send, message_recv) = unbounded();
|
||||
let (cancel_send, cancel_recv) = unbounded();
|
||||
let enabled = options.cargo_watch_enable;
|
||||
std::thread::spawn(move || {
|
||||
if !check_enabled {
|
||||
if !enabled {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,9 +32,10 @@ pub struct ServerConfig {
|
|||
|
||||
pub max_inlay_hint_length: Option<usize>,
|
||||
|
||||
pub cargo_check_enable: bool,
|
||||
pub cargo_check_command: Option<String>,
|
||||
pub cargo_check_args: Vec<String>,
|
||||
pub cargo_watch_enable: bool,
|
||||
pub cargo_watch_args: Vec<String>,
|
||||
pub cargo_watch_command: String,
|
||||
pub cargo_watch_all_targets: bool,
|
||||
|
||||
/// For internal usage to make integrated tests faster.
|
||||
#[serde(deserialize_with = "nullable_bool_true")]
|
||||
|
|
@ -55,9 +56,10 @@ impl Default for ServerConfig {
|
|||
use_client_watching: false,
|
||||
lru_capacity: None,
|
||||
max_inlay_hint_length: None,
|
||||
cargo_check_enable: true,
|
||||
cargo_check_command: None,
|
||||
cargo_check_args: vec![],
|
||||
cargo_watch_enable: true,
|
||||
cargo_watch_args: Vec::new(),
|
||||
cargo_watch_command: "check".to_string(),
|
||||
cargo_watch_all_targets: true,
|
||||
with_sysroot: true,
|
||||
feature_flags: FxHashMap::default(),
|
||||
cargo_features: Default::default(),
|
||||
|
|
|
|||
|
|
@ -127,9 +127,10 @@ pub fn main_loop(
|
|||
.and_then(|it| it.line_folding_only)
|
||||
.unwrap_or(false),
|
||||
max_inlay_hint_length: config.max_inlay_hint_length,
|
||||
cargo_check_enable: config.cargo_check_enable,
|
||||
cargo_check_command: config.cargo_check_command,
|
||||
cargo_check_args: config.cargo_check_args,
|
||||
cargo_watch_enable: config.cargo_watch_enable,
|
||||
cargo_watch_args: config.cargo_watch_args,
|
||||
cargo_watch_command: config.cargo_watch_command,
|
||||
cargo_watch_all_targets: config.cargo_watch_all_targets,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -35,9 +35,10 @@ pub struct Options {
|
|||
pub supports_location_link: bool,
|
||||
pub line_folding_only: bool,
|
||||
pub max_inlay_hint_length: Option<usize>,
|
||||
pub cargo_check_enable: bool,
|
||||
pub cargo_check_command: Option<String>,
|
||||
pub cargo_check_args: Vec<String>,
|
||||
pub cargo_watch_enable: bool,
|
||||
pub cargo_watch_args: Vec<String>,
|
||||
pub cargo_watch_command: String,
|
||||
pub cargo_watch_all_targets: bool,
|
||||
}
|
||||
|
||||
/// `WorldState` is the primary mutable state of the language server
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue