withastro / language-tools

Language tools for Astro
MIT License
262 stars 52 forks source link

🐛 BUG: cannot find Astro installation with `yarn berry` #659

Open lucas-labs opened 11 months ago

lucas-labs commented 11 months ago

Describe the Bug

Intellisense doesn't seem to get along with yarn berry.

I've installed the sdk, and configured the ls-path option accordingly

sdk

// user settings

{
    // also tried relative paths, \\, etc, just in case; but still doesn't work
    "astro.language-server.ls-path": "D:/dev/astro/.yarn/sdks/@astrojs/language-server/bin/nodeServer.js"
}

This is how it looks:

bug

As you can see in the image above, the Astro variable is being recognized as a global variable, but it is coming as if it were of type any, and since its type is any, intellisense dies right there:

no-intellisense

There's not errors or warnings in the output logs.

I'm testing this on win11, I'll try it on macos and ubuntu next week when I get back from vacation

Steps to Reproduce

  1. yarn create astro
  2. yarn add @astrojs/language-server - this is to let yarn know it has to install the astro sdk
  3. yarn dlx @yarnpkg/sdks vscode - yarn will detect astro and install the sdk
  4. set vscode user setting astro.language-server.ls-path to path/to/repo/astro/.yarn/sdks/@astrojs/language-server/bin/nodeServer.js
  5. No intellisense :(
Princesseuh commented 11 months ago

That's not intellisense not working, that's it not finding the Astro installation. I don't think this is yarn berry specific, it tries to find it from the root of your workspace (through a simple require.resolve)

imballinst commented 11 months ago

I think this is similar with https://github.com/withastro/language-tools/issues/655, I also experience Intellisense not working. But only when I'm using nodeLinker: pnp though. When I have nodeLinker: pnpm, it's working normally. Might be something-something with the existence of node_modules folder.

mikemykhaylov commented 9 months ago

Hmm, I get a different error when running steps 1-3:

[Error - 3:32:51 PM] Server initialization failed.
  Message: Request initialize failed with message: ENOTDIR: not a directory, stat '/Users/homedir/.yarn/berry/cache/@volar-language-server-npm-1.10.10-3fb40bf23d-10c0.zip/node_modules/@volar/language-server/out/common/features/customFeatures.js'
  Code: -32603 
[Error - 3:32:51 PM] Astro Language Server client: couldn't create connection to server.
  Message: Request initialize failed with message: ENOTDIR: not a directory, stat '/Users/homedir/.yarn/berry/cache/@volar-language-server-npm-1.10.10-3fb40bf23d-10c0.zip/node_modules/@volar/language-server/out/common/features/customFeatures.js'
  Code: -32603 

Looks like it does find it, but not sure why it complains about a volar language server. Installing @volar/language-server and rerunning yarn dlx @yarnpkg/sdks vscode doesn't fix it either