diff --git a/crates/tinymist-package/src/lib.rs b/crates/tinymist-package/src/lib.rs index bc66a7e82..dfa0d20c5 100644 --- a/crates/tinymist-package/src/lib.rs +++ b/crates/tinymist-package/src/lib.rs @@ -4,4 +4,4 @@ pub mod pack; pub use pack::*; pub mod registry; -pub use registry::{PackageError, PackageRegistry, PackageSpec}; +pub use registry::{PackageError, PackageRegistry, PackageSpec, PackageSpecExt}; diff --git a/crates/tinymist-query/src/fixtures/hover/package_import_local.typ b/crates/tinymist-query/src/fixtures/hover/package_import_local.typ new file mode 100644 index 000000000..f2d04069b --- /dev/null +++ b/crates/tinymist-query/src/fixtures/hover/package_import_local.typ @@ -0,0 +1 @@ +#import /* position after */ "@local/local-example:0.0.1" diff --git a/crates/tinymist-query/src/fixtures/hover/package_import.typ b/crates/tinymist-query/src/fixtures/hover/package_import_not_found.typ similarity index 100% rename from crates/tinymist-query/src/fixtures/hover/package_import.typ rename to crates/tinymist-query/src/fixtures/hover/package_import_not_found.typ diff --git a/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import_local.typ.snap b/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import_local.typ.snap new file mode 100644 index 000000000..d7732bd8e --- /dev/null +++ b/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import_local.typ.snap @@ -0,0 +1,16 @@ +--- +source: crates/tinymist-query/src/hover.rs +expression: content +input_file: crates/tinymist-query/src/fixtures/hover/package_import_local.typ +--- +Range: 0:29:0:57 + +â„šī¸ This is a local package + +**Package:** `@local/local-example:0.0.1` +✅ **Up to date** (latest version) + +**Description:** example package (mock). + +**Available Versions** (click to replace): +- **0.0.1** / diff --git a/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import.typ.snap b/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import_not_found.typ.snap similarity index 94% rename from crates/tinymist-query/src/fixtures/hover/snaps/test@package_import.typ.snap rename to crates/tinymist-query/src/fixtures/hover/snaps/test@package_import_not_found.typ.snap index 49de92819..173223e35 100644 --- a/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import.typ.snap +++ b/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import_not_found.typ.snap @@ -1,7 +1,7 @@ --- source: crates/tinymist-query/src/hover.rs expression: content -input_file: crates/tinymist-query/src/fixtures/hover/package_import.typ +input_file: crates/tinymist-query/src/fixtures/hover/package_import_not_found.typ --- Range: 0:29:0:52 diff --git a/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import_upgrade.typ.snap b/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import_upgrade.typ.snap index 0c429c6d5..1a36be822 100644 --- a/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import_upgrade.typ.snap +++ b/crates/tinymist-query/src/fixtures/hover/snaps/test@package_import_upgrade.typ.snap @@ -8,7 +8,7 @@ Range: 0:29:0:53 🌌 [Universe](https://typst.app/universe/package/example) **Package:** `@preview/example:0.1.0` -âš ī¸ **Newer version available:** 0.1.1 +âš ī¸ **Newer version available: 0.1.1** **Description:** example package (mock). diff --git a/crates/tinymist-query/src/hover.rs b/crates/tinymist-query/src/hover.rs index 736e822ae..e2de3e41f 100644 --- a/crates/tinymist-query/src/hover.rs +++ b/crates/tinymist-query/src/hover.rs @@ -3,7 +3,7 @@ use std::cmp::Reverse; use std::str::FromStr; use tinymist_std::typst::TypstDocument; -use tinymist_world::package::PackageSpec; +use tinymist_world::package::{PackageSpec, PackageSpecExt}; use typst::foundations::repr::separated_list; use typst_shim::syntax::LinkedNodeExt; @@ -247,9 +247,6 @@ impl HoverWorker<'_> { package_spec: &PackageSpec, import_str_node: &LinkedNode, ) -> String { - #[cfg(feature = "local-registry")] - use tinymist_world::package::registry::PackageSpecExt; - let versionless_spec = package_spec.versionless(); // Get all matching packages @@ -310,7 +307,7 @@ impl HoverWorker<'_> { } // Package header - if package_spec.namespace == "local" { + if !package_spec.is_preview() { info.push_str("â„šī¸ This is a local package\n\n"); } diff --git a/crates/tinymist-query/src/tests.rs b/crates/tinymist-query/src/tests.rs index 8b25d54a4..bdfbcb841 100644 --- a/crates/tinymist-query/src/tests.rs +++ b/crates/tinymist-query/src/tests.rs @@ -105,6 +105,7 @@ pub fn run_with_ctx_( vec![ dummy_package_from_spec(&PackageSpec::from_str("@preview/example:0.1.0").unwrap()), dummy_package_from_spec(&PackageSpec::from_str("@preview/example:0.1.1").unwrap()), + dummy_package_from_spec(&PackageSpec::from_str("@local/local-example:0.0.1").unwrap()), ] }); ctx.test_completion_files(|| paths.clone());