-
Notifications
You must be signed in to change notification settings - Fork 330
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
feature: add multi-root projects support #5033
Conversation
metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/Compilers.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/MetalsHttpServer.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most difficult issue might be the MetalsLogger, I wonder if we could inherit from scribe.file.FileWriter
and use LogRecord
to figure out which workspace to log to. There is filename
there but it might be just the name.scala
part. We might need to just log either to first workspace or to all of them.
Potentially, we could have activeWorkspace
and only log to the last active one, but that might not work very well 🤔
metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/MetalsLspWorkspaceFolderService.scala
Outdated
Show resolved
Hide resolved
It feels like it would be best to figure out which one to log to for current file and log to all for global things. Last active feels like it could be confusing and flaky. |
metals/src/main/scala/scala/meta/internal/metals/doctor/Doctor.scala
Outdated
Show resolved
Hide resolved
fe12683
to
7abfaa9
Compare
d2bbb72
to
17b5964
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I added a bunch of comments, but most of your changes are really great and we only need to polish it.
metals/src/main/scala/scala/meta/internal/metals/Compilers.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/GithubNewIssueUrlCreator.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala/scala/meta/internal/pc/CompletionItemData.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/WorkspaceLspService.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/metals/WorkspaceLspService.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/tvp/MetalsTreeViewProvider.scala
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
class MetalsTreeFolderViewProvider( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you show an example of how does the tree view look like currently? With multiple folders and without?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could use a bit more granularity, but the only thing I would change is not to add the name if we only have a single one and maybe do it like Projects (coursier)
val libraries = new ClasspathTreeView[AbsolutePath, AbsolutePath]( | ||
definitionIndex, | ||
TreeViewProvider.Project, | ||
s"libraries-${folder.uri.toString()}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have another folder level and libraries/project underneath? Possibly without that level if we only have one folder. We can change it in a later PR if this proves difficult.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the screenshots, I think it's okay as a flattened structure. But I can change it, if you think it'll be better.
This is fantastic @kasiaMarek! I'd love to try this out with nvim-metals to also ensure that this will work with other editors, especially ones like neovim that sort of have an artificial concept of a workspace. Could you maybe outline what the intended flow of an editor is to use this? For example will this fully support Looking forward to trying this out! |
@ckipp01 yes, it adds suport for |
|
||
private def createServices(folders: List[Folder]): List[MetalsLspService] = | ||
folders | ||
.withFilter { case Folder(uri, _) => !BuildTools.default(uri).isEmpty } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filter out the folders that don't have a build tool defined. @tgodzik, does this seem reasonable? My intuition was that you may have also non-Scala projects. All the scala files from such folders will be handled by the default
service.
This might be tricky, we might want to put a note about it in here under a section explaining how we use multi-root.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! This was some great work! I took the liberty to push a couple of small changes since @kasiaMarek is out today.
Really really fantastic work @kasiaMarek 🚀 Thinking ahead a bit, do you think we should document this a bit somewhere? I'm mainly thinking not only for users, but also for client maintainers we're likely going to get questions like:
It might be a good idea to answer some of these before the next release to help people out that want to try this out. Maybe a section on the website? Or even outline it on the architecture.md document? |
just spotted this, amazing! |
This PR adds support for multi-root project (workspace folders). It adds support for:
didChangeWorkspaceFolders
.Added server capabilities:
Metals architecutre for multi-root projects.
Tasks:
didChangeWorkspaceFolders
Docs:
In followups we should:
Resolves: #5188