Skip to content

Commit 40e7b56

Browse files
committed
add diagnostic interval config
1 parent b1c4e43 commit 40e7b56

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

crates/code_analysis/src/config/configs/diagnostics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub struct EmmyrcDiagnostic {
2828
/// A list of diagnostic codes that are enabled.
2929
#[serde(default)]
3030
pub enables: Vec<DiagnosticCode>,
31+
/// The interval in milliseconds to perform diagnostics.
32+
pub diagnostic_interval: Option<u64>,
3133
}
3234

3335
impl Default for EmmyrcDiagnostic {
@@ -39,6 +41,7 @@ impl Default for EmmyrcDiagnostic {
3941
globals_regex: Vec::new(),
4042
severity: HashMap::new(),
4143
enables: Vec::new(),
44+
diagnostic_interval: Some(500),
4245
}
4346
}
4447
}

crates/emmylua_ls/src/context/file_diagnostic.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ impl FileDiagnostic {
4444
drop(tokens); // free the lock
4545

4646
let analysis = self.analysis.clone();
47+
let emmyrc = analysis.read().await.get_emmyrc();
48+
let interval = emmyrc.diagnostics.diagnostic_interval.unwrap_or(500);
4749
let client = self.client.clone();
4850
let diagnostic_tokens = self.diagnostic_tokens.clone();
4951
let file_id_clone = file_id.clone();
5052

5153
// Spawn a new task to perform diagnostic
5254
tokio::spawn(async move {
5355
tokio::select! {
54-
_ = tokio::time::sleep(Duration::from_millis(500)) => {
56+
_ = tokio::time::sleep(Duration::from_millis(interval)) => {
5557
let analysis = analysis.read().await;
5658
if let Some(uri) = analysis.get_uri(file_id_clone) {
5759
let diagnostics = analysis.diagnose_file(file_id_clone, cancel_token).await;

resources/schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
},
3737
"diagnostics": {
3838
"default": {
39+
"diagnosticInterval": 500,
3940
"disable": [],
4041
"enable": true,
4142
"enables": [],
@@ -413,6 +414,15 @@
413414
"description": "Represents the diagnostic configuration for Emmyrc.",
414415
"type": "object",
415416
"properties": {
417+
"diagnosticInterval": {
418+
"description": "The interval in milliseconds to perform diagnostics.",
419+
"type": [
420+
"integer",
421+
"null"
422+
],
423+
"format": "uint64",
424+
"minimum": 0.0
425+
},
416426
"disable": {
417427
"description": "A list of diagnostic codes that are disabled.",
418428
"default": [],

0 commit comments

Comments
 (0)