Skip to content

use umbrella root formatter config when present#35

Open
superhawk610 wants to merge 2 commits intoremoteoss:mainfrom
superhawk610:fix/umbrella-root-formatter
Open

use umbrella root formatter config when present#35
superhawk610 wants to merge 2 commits intoremoteoss:mainfrom
superhawk610:fix/umbrella-root-formatter

Conversation

@superhawk610
Copy link
Copy Markdown

Closes #34.

Given this file tree:

| mix.exs
| .formatter.exs
/ apps
  / app_web
    | mix.exs
    / lib
      | component.ex

When formatting apps/app_web/lib/component.ex, the umbrella root .formatter.exs should be used.

I'm not confident that the approach I took to solve this, namely having findMixRoot return (appRoot, umbrellaRoot string), is the best. It requires passing around both the app root and umbrella roots whenever resolving a formatter. It may be easier to identify the correct formatter file earlier and just pass that around instead.

@JesseHerrick
Copy link
Copy Markdown
Collaborator

Hi @superhawk610, thank you for the contribution! I would suggest a modification to the approach to handle both umbrella apps and monorepos:

Rather than walking up to the umbrella root, we should keep walking up to the project root (which would be the same as the umbrella root in your example). This way we handle monorepos with strange .formatter.exs config as well, and it keeps things clean around the project root. Functionally, it should be very similar, but it avoids introducing the concept of an umbrella root into the code at all. What do you think?

@superhawk610
Copy link
Copy Markdown
Author

superhawk610 commented Apr 16, 2026

That makes sense! Does the LSP have access to a project root directory set in the config somewhere, or should we just recurse some arbitrary number of directories upward until we find a .formatter.exs or give up?

EDIT: Ahh, I see Server.projectRoot, that's just what I needed.

findMixRoot will now look for the mix root closest to the project root instead of closest to the file we're formatting. findFormatterConfig should still find the .formatter.exs closest to the file.

@JesseHerrick
Copy link
Copy Markdown
Collaborator

Thanks @superhawk610! I haven't forgotten about this - I have just been busy with a few other things. Will review sometime this week!

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.

Root .formatter.exs support for umbrella projects

2 participants