elt547

elt547

How can I start using the new Heex formatter in VS Code?

I’ve been fighting a little bit of a battle with my formatters in vs code. I’m not even sure what is formatting my heex at the moment, but I’m left with blocks looking like:

    <div class="mb-2">
      <%= label f, :description, class: "block font-semibold mb-1 text-slate-500" %>
        <%= text_input f, :description, class: "w-full text-input" %>
          <%= error_tag f, :description %>
    </div>

How can I take advantage of the new formatter that @chrismccord mentioned in his talk at the recent elixir conference? I’m not a regular user of vs code and the settings are often quite confusing to me.

Most Liked

lubien

lubien

@elt547 you might want to install heex formatter:

For LiveView 0.18: Phoenix.LiveView.HTMLFormatter — Phoenix LiveView v0.18.3

Here are some general tips for setting up vscode

And if auto formatter doesn’t kick in I’ve setup q hack for myself using a extension from vscode that I think is called “run on save” but liveview 0.18 might not need it, I haven’t tested it yet

Hopefully one of those tips might help

bdarla

bdarla

I am not sure that this is what you are looking for, but the following formatting works for me fine.

The relevant parts for settings.json are:

"editor.formatOnSave": true,
"[elixir]": {
    "editor.defaultFormatter": "animus-coop.vscode-elixir-mix-formatter"
  },
  "[phoenix-heex]": {
    "editor.defaultFormatter": "JakeBecker.elixir-ls"
  },
"files.associations": {
    "*.heex": "phoenix-heex"
  },

and for my .formatter.exs:

[
  import_deps: [:ecto, :phoenix],
  plugins: [Phoenix.LiveView.HTMLFormatter],
  inputs: ["*.{heex,ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{heex,ex,exs}"],
  subdirectories: ["priv/*/migrations"]
]

The relevant plugins I have installed are “ElixirLS: Elixir support and debugger”, “Phoenix Framework”. “Elixir Mix Formatter” and “Heex HTML”.

Where Next?

Popular in Questions Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
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

We're in Beta

About us Mission Statement