Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the LSP from workspace #9

Merged
merged 10 commits into from
Apr 20, 2024

Conversation

chungweileong94
Copy link
Contributor

The extension will use the LSP in the workspace (installed by the user), and then fallback to the default LSP if it doesn't exist.

Related #6

@chungweileong94 chungweileong94 marked this pull request as ready for review April 19, 2024 15:33
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question, then I think we can try to release a new version

Comment on lines +27 to +28
!f["dependencies"]["@biomejs/biome"].is_null()
|| !f["devDependencies"]["@biomejs/biome"].is_null()
Copy link
Member

@ematipico ematipico Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this error if dependencies or devDependencies fields aren't inside the package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested a bit, it will return null if one of the fields is non-existent. But feel free to test it again.

// This is a workaround, as reading the file from wasm doesn't work.
// Instead we try to read the `package.json`, see if `@biomejs/biome` is installed
let package_json = worktree
.read_text_file("package.json")
Copy link
Contributor Author

@chungweileong94 chungweileong94 Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the existence of the LSP binary in the workspace with fs::metadata doesn't work, probably because of wasm. Instead, we can read the package.json with worktree::read_text_file and find out if the user has included the @biomejs/biome as part of dependencies or devDependencies.

Originally I was trying to read the node_modules/@biomejs/biome/package.json with worktree::read_text_file, just to check if the user already installed the package, but it doesn't work for some reason.

@ematipico ematipico merged commit f526cb9 into biomejs:main Apr 20, 2024
2 checks passed
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.

2 participants