Skip to content

Commit 2863f13

Browse files
committed
Click on directory -> default.nix
1 parent 3f8fb49 commit 2863f13

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

src/hover.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,16 @@ pub async fn hover(
5656
}
5757
if let HoverOrigin::Path(path) = strategy.origin {
5858
let md = format!("```\n{}\n```", path.display());
59+
let default_nix_path = path.join("default.nix");
60+
let goto_path = if path.is_dir() && default_nix_path.exists() {
61+
default_nix_path
62+
} else {
63+
path
64+
};
5965
let position = Some(Position {
6066
line: 1,
6167
col: 1,
62-
path,
68+
path: goto_path,
6369
});
6470
return Ok(HoverResult { md, position });
6571
}
@@ -630,6 +636,23 @@ mod test {
630636
.await;
631637
}
632638

639+
#[test_log::test(tokio::test)]
640+
async fn test_hover_default_nix_path() {
641+
check_hover_nixpkgs(
642+
"default.nix",
643+
indoc! {"
644+
import ./l$0ib
645+
"},
646+
expect![[r#"
647+
/test/hello/world/other.nix:1:1
648+
649+
```
650+
/test/hello/world/other.nix
651+
```"#]],
652+
)
653+
.await;
654+
}
655+
633656
#[test_log::test(tokio::test)]
634657
async fn test_hover_nixpkgs_lib() {
635658
check_hover_nixpkgs(

0 commit comments

Comments
 (0)