biomejs / biome-zed

Biome extension for Zed
https://biomejs.dev
MIT License
127 stars 4 forks source link

Version 0.1.0 failed to locate biome language server #33

Closed chungweileong94 closed 1 month ago

chungweileong94 commented 1 month ago

In version 0.1.0, the extension doesn't able to locate the biome language server, which likely due to this change https://github.com/biomejs/biome-zed/commit/be0e8868d042ff3cceae74a035fb2fc0d0eb198b.

My current workaround is to customize the lsp binary in settings

"lsp": {
  "biome": {
    "binary": {
      "path": "node_modules/@biomejs/biome/bin/biome",
      "arguments": ["lsp-proxy"]
    }
  }
}
chungweileong94 commented 1 month ago

So I installed biome via pnpm, and based on my understanding, biome will download the binary via postinstall script, which pnpm will put them under node_modules/.pnpm/@biomejs+biome@1.7.3/node_modules/@biomejs/cli-xxx-xxx. Which mean we have to do more than just node_modules/@biomejs/cli-xxx-xxx if we want to run it without Node.

ematipico commented 1 month ago

pnpm creates a symbolic link though, so node_modules/@biomejs/cli-xxx-xxx is still valid. Just need to follow the symbolic link, correct?

chungweileong94 commented 1 month ago

pnpm creates a symbolic link though

Yes, but apparently pnpm don't create symlink in node_modules/@biomejs/cli-xxx-xxx🫤. I think pnpm won't includes any at the root of node_modules that is not directly consumed by the user (dependencies in package.json). Unless we configure the hoist pattern https://pnpm.io/npmrc#hoist-pattern

luckydye commented 1 month ago

Yeah... I guess we need to fallback to the node script.

luckydye commented 1 month ago

I'm trying to use oxc_resolver, but it just resolves to "/node_modules/@biomejs/cli-darwin-arm64/biome" :/ which is wrong. (https://github.com/biomejs/biome-zed/tree/fix/resolve-binary)

ematipico commented 1 month ago

I believe we need to do it ourselves, I think. Check if the binary is a symbolic link and follow it

luckydye commented 1 month ago

So the node_modules look like this:

image

"optionalDependencies" are not linked directly under node_modules, which means we don't really have a link to follow.. :/

ematipico commented 1 month ago

Ah, what a bummer :/

nhedger commented 1 month ago

For the VS Code extension, I had to resolve the cli packages in the context of the @biomejs/biome packages. I wonder if it's possible with oxc_resolver.

https://github.com/biomejs/biome-vscode/blob/45a46c4414e1a4b396c0fa427319a041c1701358/src/main.ts#L436-L466

chungweileong94 commented 1 month ago

I checked the VSCode extension, it reminds me of yarn pnp, which I think this extension doesn't work OOB, but I think that can be fixed separately.