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

Rust Analyzer doesn't work with multiple subprojects #5108

Open
1 task done
reduxdj opened this issue Nov 24, 2022 · 11 comments · May be fixed by #22182
Open
1 task done

Rust Analyzer doesn't work with multiple subprojects #5108

reduxdj opened this issue Nov 24, 2022 · 11 comments · May be fixed by #22182
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc language An umbrella label for all programming languages syntax behaviors rust Rust programming language support

Comments

@reduxdj
Copy link

reduxdj commented Nov 24, 2022

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Syntax highlight on nested sub projects from the file browser, does not syntax highlight (in Rust), other non-nested projects, syntax highlighting still works...

Expected behavior

Expect syntax highlighting, command clicking and all things to work no matter if its nested n levels deep.

Environment

echo $(zed --version) "\n"macOS $(sw_vers -productVersion) "\n"architecture $(uname -m)

Zed 0.65.2 – /Applications/Zed.app
macOS 12.5.1
architecture arm6

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue

No response

@reduxdj reduxdj added bug [core label] triage Maintainer needs to classify the issue labels Nov 24, 2022
@reduxdj
Copy link
Author

reduxdj commented Nov 24, 2022

by the way opening directly from surrounding directory works, for instance, navigating directly to sub directory and issuing a zed . syntax highlighting returns ...

@maxbrunsfeld
Copy link
Collaborator

Thanks for the report. Can you explain this a bit further with a specific example? I don't understand how how the project file browser relates to syntax highlighting, and what exactly you're seeing.

@JosephTLyons JosephTLyons added needs info / awaiting response Issue that needs more information from the user editor Feedback for code editing, formatting, editor iterations, etc rust Rust programming language support language An umbrella label for all programming languages syntax behaviors and removed triage Maintainer needs to classify the issue labels Nov 27, 2022
@reduxdj
Copy link
Author

reduxdj commented Nov 30, 2022

OK, i can't really show you my current work project, but for some reason I have a project path that looks like the following, when i hover over a directory from opening the project directory syntax highlighting doesn't work.

project/rust/some_app/main.rs
project/rust/some_app/cargo.toml

and if the the some_app folder directly, then the syntax highlighting works. It seems like subfolders more than 1 level deep syntax highlighting fails for these folders. I had another engineer on our team notice the same thing and the work around also works for them as well.

@eth0net
Copy link
Contributor

eth0net commented Dec 16, 2022

I believe I'm running into the same problem here, with language servers only working if a Cargo.toml or go.mod etc is found in the root of the project.

Rust and Go aren't working when I open the root of the repo, but Rust is working as normal if I open the aoc2201 directory itself.

Screenshot 2022-12-16 at 10 49 23

Not sure on best practices for handling multiple language servers simultaneously, but this works in VS Code and IntelliJ, and I 100% prefer Zed 🤣

@eth0net
Copy link
Contributor

eth0net commented Dec 17, 2022

I found a cargo workspace in the project root solved my issue, so posting it in case it helps others 😄

Just create a workspace Cargo.toml file with all your sub projects included 🥳

Screenshot 2022-12-17 at 12 14 07

@JosephTLyons JosephTLyons removed the needs info / awaiting response Issue that needs more information from the user label Mar 30, 2023
@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@eth0net
Copy link
Contributor

eth0net commented Apr 17, 2024

Noticed this issue has the Rust label, though it applies to Go as well, and may not be limited to those two.

The issue is that Zed isn't loading LSPs without seeing appropriate files (i.e. Cargo.toml) in the root of a project folder and ignores such files found in subdirectories.

To address this, Zed could recursively check each directory to see if it's a LSP-worthy project, or require project roots to be workspaces to handle nested projects. There might be a way to create virtual cargo/go workspaces without the user defining them, but that might be over-complicating things.

Going to test to see if this is still present before trying to think on this more 🤔

@eth0net
Copy link
Contributor

eth0net commented Apr 17, 2024

Looks like this issue has already been fixed to me!
Screenshot 2024-04-17 at 09 29 23

@eth0net
Copy link
Contributor

eth0net commented Apr 17, 2024

Oh I've run into the issue again, but with the Zed extensions repo! Might be that one level of nesting works but not more. Going to open a PR to add a workspace file there to account for it.

@eth0net
Copy link
Contributor

eth0net commented Apr 17, 2024

Yep, this fails
Screenshot 2024-04-17 at 12 40 45

And this works

Screenshot 2024-04-17 at 12 44 21

Copy link

github-actions bot commented Oct 15, 2024

Hi there! 👋
We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. Are you able to reproduce this issue in the latest version of Zed? If so, please let us know by commenting on this issue and we will keep it open; otherwise, we'll close it in 7 days. Feel free to open a new issue if you're seeing this message after the issue has been closed.
Thanks for your help!

@github-actions github-actions bot added the stale Label used by `stale` action label Oct 15, 2024
@github-actions github-actions bot removed the stale Label used by `stale` action label Oct 29, 2024
@osiewicz
Copy link
Contributor

Thanks for confirming it @eth0net ! I'll take a look in a near-ish term at improving this part of our LSP handling.

@osiewicz osiewicz changed the title Syntax highlight on nested sub projects from the file browser - command clicking completely not functional Rust Analyzer doesn't work with multiple subprojects Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc language An umbrella label for all programming languages syntax behaviors rust Rust programming language support
Projects
None yet
5 participants