elixir-lsp / vscode-elixir-ls

Elixir language support and debugger for VS Code, powered by ElixirLS.
https://marketplace.visualstudio.com/items?itemName=JakeBecker.elixir-ls
MIT License
539 stars 106 forks source link

Multi-root workspace with independent mix projects when the root folder is also a mix project #424

Closed vheathen closed 2 months ago

vheathen commented 3 months ago

The issue is related to #313 , but a bit different.

Before I was using the extension with multi-root workspaces where each root was containing an Elixir app.

But now I'm trying to adapt Workspace to organize monorepo project, and the vscode workspace root got its own mix.exs. I can set projectRoot, but then I can have only one active Elixir project, and I need to have many.

In my case the structure looks like this:

/ (repo and vscode workspace root)
┣ .workspace (contains some config for tools, has nothing to do with Elixir)
┣ apps/
┃ ┗ app-a/
┃ ┃ ┗ mix.exs
┃ ┗ app-b/
┃   ┗ mix.exs
┣ packages
┃ ┗ packages-a/
┃ ┃ ┗ mix.exs
┃ ┗ packages-a/
┃ ┃ ┗ mix.exs
┃ ┗ packages-c/
┃   ┗ mix.exs
┣ .formatter.exs
┣ .gitignore.exs
┣ .workspace.exs
┣ mix.exs
┗ project.code-workspace

I need to have apps/app-X, packages/package-X et al. as separate workspace root folders, but I also need the main root as well as I need to work within it and be able to run mix tasks.

I believe it worth to introduce a setting useCurrentRootFolderAsProjectDir with false as default to restrict looking for the mix.exs in the current directory only. It would keep backward compatibility, at the same time allowing to have such configuration.

The PR is following.