Skip to content

Commit 8951cf6

Browse files
committed
Schema when lambda or let
1 parent 5824981 commit 8951cf6

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

src/hover.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ fn get_hover_strategy(source: &str, file_info: &FileInfo, offset: u32) -> Option
216216
let mut schema = schema;
217217
for attr in attrpath.attrs().take(index + 1) {
218218
schema = schema.attr_subschema(&attr).clone();
219-
eprintln!("subschema {:?}", schema);
220219
}
221220

222221
Some(HoverStrategy {
@@ -528,4 +527,44 @@ mod test {
528527
)
529528
.await;
530529
}
530+
531+
#[test_log::test(tokio::test)]
532+
async fn test_hover_lambda() {
533+
check_hover_with_filetype(
534+
r#"{ pkgs }: { programs.zsh.enableAutosug$0gestions = false; }"#,
535+
expect![[r#"
536+
no position
537+
538+
### option `programs.zsh.enableAutosuggestions`
539+
Alias of {option}`programs.zsh.autosuggestion.enable`.
540+
541+
*Type:* boolean
542+
"#]],
543+
&FileType::Package {
544+
nixpkgs_path: env!("NIXPKGS").to_string(),
545+
schema: HOME_MANAGER_SCHEMA.clone(),
546+
},
547+
)
548+
.await;
549+
}
550+
551+
#[test_log::test(tokio::test)]
552+
async fn test_hover_lambda_let() {
553+
check_hover_with_filetype(
554+
r#"{ pkgs }: let four = 2+2; in { programs.zsh.enableAutosug$0gestions = false; }"#,
555+
expect![[r#"
556+
no position
557+
558+
### option `programs.zsh.enableAutosuggestions`
559+
Alias of {option}`programs.zsh.autosuggestion.enable`.
560+
561+
*Type:* boolean
562+
"#]],
563+
&FileType::Package {
564+
nixpkgs_path: env!("NIXPKGS").to_string(),
565+
schema: HOME_MANAGER_SCHEMA.clone(),
566+
},
567+
)
568+
.await;
569+
}
531570
}

src/schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub fn get_schema(expr: &Expr, file_info: &FileInfo) -> Arc<Schema> {
108108
None => return Arc::new(Schema::default()),
109109
}
110110
}
111+
Expr::LetIn(_) | Expr::Lambda(_) | Expr::With(_) => {}
111112
_ => return Arc::new(Schema::default()),
112113
}
113114
}

0 commit comments

Comments
 (0)