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

blackode
Elixir Upgrading is so Simple in Ubuntu and It worked for me Ubuntu 16.04 git clone https://github.com/elixir-lang/elixir.git cd elixir...
New
Rustixir
Hi everyone, im working on find best language/framework/system for high concurrency, high performance and stable performance after wor...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
Crowdhailer
I’ve been hearing much about the new formatter and it’s something I have been keen to try. I find examples buy far the most illuminating...
248 19204 150
New
mbenatti
Following https://github.com/tbrand/which_is_the_fastest |> https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
sergio
There’s a new TIOBE index report that came out that shows Elixir is still not in the top 50 used languages. It also goes on to call Elix...
New
rower687
Hi all, I’ve been reading a lot about the “let it crash” term and how supervising processes and the whole messaging passing make an elixi...
New
100phlecs
Are there any downsides, like perf issues, to putting all functional components in CoreComponents as long as you prefix it with the conte...
New
AstonJ
If so I (and hopefully others!) might have some tips for you :slight_smile: But first, please say which area you’re finding most challen...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
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
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
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
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

We're in Beta

About us Mission Statement