melomario

melomario

Mix-format daemon

Is there anyway to keep “mix format” running and watching files on a specific directory?

I tried to run it automatically whenever I save a file, but it takes some time and I’m that kind of dev that saves pretty much everytime. :stuck_out_tongue:

I might be wrong, but I feel that a great deal of the time it takes to format the file is related to starting mix up.

Marked As Solved

dbern

dbern

I’m not aware of a daemon, but I do know that editors can take advantage of ElixirLS which is a server running in the background (like a daemon I suppose) and perform tasks like formatting your code. You can adjust settings in your editor to format on save or on-demand. Might be faster to use ElixirLS than spinning up mix to format each time.

Which editor do you use?

Also Liked

hauleth

hauleth

The problem with that is that it would modify file twice. You can “hand craft” something like that by using entr(1), however I would say that you should use pre-save hook in your editor.

stefanchrobot

stefanchrobot

Here’s what I’m using (auto format and re-run affected tests):

watchexec -e 'ex,exs,eex,leex' -- 'mix format && mix test --stale'

You need to configure your editor to properly pick up external changes automatically and not nag you with a popup.

NobbZ

NobbZ

Your client need to support the code format action.

I know nothing about which features are supported by coc.vim. You need to consult its documentation.

Or perhaps @hauleth can help you. I know he uses vim + elixir-ls, though I do not know which client he uses.

slouchpie

slouchpie

if you have a program like say or speak, you can do really fun stuff like:

ls **/*.{ex,exs,heex} | entr sh -c "mix format; mix test && say 'tests all green' || say 'we have a problem, some test failed'" 

Where Next?

Popular in Questions Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
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
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
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
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
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
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
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
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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
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
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
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement