Skip to content

Conversation

@thomasquinn
Copy link

This PR adds support for resolving modulepath: URIs using the module paths declared in a PklProject's evaluatorSettings, as the CLI does. This is a different approach than #93, which instead adds an LSP setting for these paths. Let me know if you'd prefer that approach over using evaluatorSettings.modulePath. I thought that using the standard PklProject setting may avoid a bit of editor setup for users and allow the LSP to match the CLI's behavior more closely.

This is my first time writing Kotlin, so please tell me if there's a better way of expressing this code. In particular, I can't tell if a more functional or imperative style is typical here.

My use case for this is to have workspace root-relative imports for generated Pkl files in Bazel. As a demonstration, here is the behavior of pkl-vscode (v0.21.0, unchanged) before and after this patch to pkl-lsp, with the following PklProject:

amends "pkl:Project"

evaluatorSettings {
  modulePath {
    "."
    "./bazel-bin"
  }
}

Before ("Cannot resolve import" error on amends):
Screenshot 2025-11-22 at 6 12 32 PM

After ("Go to definition" jumpts to Example.pkl within bazel-bin):
Screenshot 2025-11-22 at 6 10 53 PM

This does not completely implement modulepath:, as it makes no attempt to read files within JARs or Zip files, which the spec (and CLI) supports.

Closes #91.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support for project/package specific modulepaths

1 participant