Sanjibukai

Sanjibukai

Formatter with Elixir-LS for umbrella project

Hi everybody,

I am working within a Phoenix Umbrella Project and I’m using Elixir-LS in VSCode.
This extension has a setting elixirLS.projectDir that allows to set the path of the project root (where the mix.exs file is located).
I tried by setting the three option I have:

  • "elixirLS.projectDir": "my_app_umbrella"
  • "elixirLS.projectDir": "my_app_umbrella/apps/my_app"
  • "elixirLS.projectDir": "my_app_umbrella/apps/my_app_web"

It’s somehow working on each of these cases, but I’m not sure if it’s working because once set all the generated files will still be available..

However something that isn’t working is the formatter. For example if I set the path to the ecto part (my_app), the schema files correctly handle the defined formatting provided by ecto (e.g. keeping field :name, :string without parentheses like field(:name, :string) but then the autoformater isn’t working on the Phoenix side (my_app_web). For example in the router file all the line like that plug :fetch_session are replaced by plug(:fetch_session)..

Here are the three .formatter.exs files:

# my_app_umbrella/.formatter.exs
[
  inputs: ["mix.exs", "config/*.exs"],
  subdirectories: ["apps/*"]
]
# my_app_umbrella/my_app/.formatter.exs
[
  import_deps: [:ecto],
  inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
  subdirectories: ["priv/*/migrations"]
]
# my_app_umbrella/my_app_web/.formatter.exs
[
  import_deps: [:phoenix],
  inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}"]
]

So I wonder if putting everything on the umbrella project will solve my problem.
I merged the arrays of every like so:

[
  import_deps: [:ecto, :phoenix],
  inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
  subdirectories: ["priv/*/migrations", "apps/*"]
]

And now everything regarding the autoformatter seems to work.

So I wanted to know what do you think?
Will it be a good idea to make this as a default?

Though, I’m not sure if merging the entries won’t have side effects..

Most Liked

lukaszsamson

lukaszsamson

ElixirLS Core Team

Unfortunately the formatter support in elixir-LS is buggy, see e.g. textDocument/formatting does not support subdirectories in .formatter.exs · Issue #361 · elixir-lsp/elixir-ls · GitHub
Personally, I only use mix format

Where Next?

Popular in Discussions Top

scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
Qqwy
I would like to spark a discussion about the static access operator: .. For whom does not know: it is used in Elixir to access fields of...
New
andre1sk
A big advantage to Elixir is all the distributed goodness but for many applications running on multiple nodes having integrated Etcd, Zoo...
New
pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
pdgonzalez872
If this has been asked here before, please point me to where it was asked as I didn’t find it when I searched the forum. Maybe a mailing ...
New
nburkley
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
matthias_toepp
I’d love to hear what people think about Wisp, the new Gleam web framework started by Gleam’s primary creator Louis Pilfold. Gleam, alon...
New

Other popular topics Top

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

We're in Beta

About us Mission Statement