starpls icon indicating copy to clipboard operation
starpls copied to clipboard

Automatically download `starpls` in VSCode

Open lalten opened this issue 7 months ago • 2 comments

I originally wanted to post about a problem we're having. I have now found out that this isn't related to starpls at all. I'm still going to post the below in case it's helpful for others 😊. Maybe it could find its way into the docs?

We're pointing the VSCode Bazel extension at starpls like this:

MODULE.bazel

bazel_dep(name = "download_utils", version = "1.0.1")
download_file = use_repo_rule("@download_utils//download/file:defs.bzl", "download_file")
download_file(
    name = "starpls",
    executable = True,
    output = "starpls",
    urls = ["https://github.com/withered-magic/starpls/releases/download/v0.1.14/starpls-linux-amd64"],
)

The settings.json is checked in to git so everyone is using the same.

.vscode/settings.json

  "bazel.lsp.args": [
    "run",
    "@starpls"
  ],
  "bazel.lsp.command": "bazel",

The benefit of this setup is that nobody has to manually install starpls, it's all handled by Bazel. It will only work on Linux, but likely that could be solved with rules_multitool

lalten avatar Jul 10 '25 13:07 lalten

Yeah this makes sense, should be easy enough to add some docs on how people can do setup with rules_multitool if they want

withered-magic avatar Jul 10 '25 17:07 withered-magic

I used this blob for the rules_multitool lockfile:

  "starpls": {
    "binaries": [
      {
        "kind": "archive",
        "url": "https://github.com/withered-magic/starpls/releases/download/v0.1.21/starpls-linux-aarch64.tar.gz",
        "file": "starpls",
        "sha256": "2d2a97b7d2ed0a63a2a9acf74d1b17b6f5edb736556c6b2315634df8de97692b",
        "os": "linux",
        "cpu": "arm64"
      },
      {
        "kind": "archive",
        "url": "https://github.com/withered-magic/starpls/releases/download/v0.1.21/starpls-linux-amd64.tar.gz",
        "file": "starpls",
        "sha256": "f236de322c86ccd7562aa6814ec481cc1d01f99b9ee165509da9dc09fdb8d418",
        "os": "linux",
        "cpu": "x86_64"
      },
      {
        "kind": "archive",
        "url": "https://github.com/withered-magic/starpls/releases/download/v0.1.21/starpls-darwin-arm64.tar.gz",
        "file": "starpls",
        "sha256": "1542edc2ed597feca65455fe87a81436e091ae06a6c4e455dc9625f5a92905fb",
        "os": "macos",
        "cpu": "arm64"
      }

Additionally we use bazel_env.bzl to setup a dev environment via direnv. The user is required to run bazel run //bazel/tools:bazel_env for setup. With that, we have checked in this as the VSCode settings:

  "bazel.lsp.command": "./bazel-out/bazel_env-opt/bin/bazel/tools/bazel_env/bin/starpls",
  "bazel.lsp.args": [
    "server",
    "--experimental_infer_ctx_attributes",
    "--experimental_use_code_flow_analysis",
    "--experimental_enable_label_completions"
  ],

This does not satisfy the automatic download as stated in the ticket. But for us developers are expected to run the bazel_env setup either way.

lukasoyen avatar Jul 21 '25 06:07 lukasoyen