hauleth

hauleth

Are You using EditorConfig?

Question as in the title. Are You using EditorConfig in your projects?

  • Yes
  • Yes, but not in Elixir projects
  • No
  • I didn’t know about EditorConfig
0 voters

Most Liked

hauleth

hauleth

For me it is irritating as the editor need to reload edited file after each save, which sometimes screw the undo (I have persistent undo in Vim enabled). Additionally it fires file watchers twice, so sometimes it can cause “wasted cycles” when running tests twice after each change.

Additionally mix format will not work with files that aren’t UTF-8. While most editors use that by default it not always can be a case, for example Windows sometimes use UTF-16 which will crash the mix format:

$ echo 'Łukasz' | iconv -f UTF-8 -t UTF-16 | mix format -
mix format failed for stdin
** (UnicodeConversionError) invalid encoding starting at <<254, 255, 1, 65, 0, 117, 0, 107, 0, 97, 0, 115, 0, 122, 0, 10>>
    (elixir 1.10.0) lib/string.ex:2223: String.to_charlist/1
    (elixir 1.10.0) lib/code/formatter.ex:198: Code.Formatter.to_algebra/2
    (elixir 1.10.0) lib/code/formatter.ex:236: Code.Formatter.to_algebra!/2
    (elixir 1.10.0) lib/code.ex:645: Code.format_string!/2
    (mix 1.10.0) lib/mix/tasks/format.ex:418: Mix.Tasks.Format.format_file/2
    (elixir 1.10.0) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir 1.10.0) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib 3.10) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
$ echo 'Łukasz' | iconv -f UTF-8 -t CP1250 | mix format -
mix format failed for stdin
** (UnicodeConversionError) invalid encoding starting at <<163, 117, 107, 97, 115, 122, 10>>
    (elixir 1.10.0) lib/string.ex:2223: String.to_charlist/1
    (elixir 1.10.0) lib/code/formatter.ex:198: Code.Formatter.to_algebra/2
    (elixir 1.10.0) lib/code/formatter.ex:236: Code.Formatter.to_algebra!/2
    (elixir 1.10.0) lib/code.ex:645: Code.format_string!/2
    (mix 1.10.0) lib/mix/tasks/format.ex:418: Mix.Tasks.Format.format_file/2
    (elixir 1.10.0) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir 1.10.0) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib 3.10) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

Yes, but it will not manage all files in projects. Erlang files or Makefiles will not be formatted via mix format. And if you configure tabstop option then GitHub will also show files in diffs and file display with proper indentation depth.

What is more, some editors (for sure Vim, but I assume that others as well) can display vertical line on the “line length limit” which is useful to write code “formatted” already, without the need for running mix format in the background. None of the editors I know can read .formatter.exs to do so (however I could easily implement that for Vim if needed).

The for me in EditorConfig is to make it pass before even being sent to the CI, as most of these “fixes” can be applied automatically by editor (proper indentation characters, indentation width, charsets, etc.). This is also handy for root = true option for a lot of tools, as this marks the “main” directory of the project and such tools can “stop” when traversing the directory tree in lookup for “root directory”.

axelson

axelson

Scenic Core Team

I marked yes, although I don’t use it in all my projects (or even most of them). But I like having it and want to use it in more projects. Even if it is only as documentation about the expected config.

hauleth

hauleth

It is more about using it anywhere. I understand that most people will not use it everywhere, because sometimes it doesn’t make sense, because internal projects not always need them.

Eiji

Eiji

For me mix format (called automatically on each file save) handles all formatting, so there is no need for such extra plugin in my editor.

I understand that it’s intended for projects with more than one developer, but if I remember correctly every commit may be rejected if specified check fails which is also possible to pair with mix format task.

Where Next?

Popular in Dev Env & Tools Top

AstonJ
Following the Is your computer's internet connection wired or wireless? (Poll) I thought it might be an idea to have an accompany thread ...
New
AstonJ
What are you using for software dev? Can you share what you like/dislike about it? Would you recommend it to others? Related thread: Ho...
New
Cervajz
Code at the speed of thought Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter. It’s also open...
New
Dusty
New England download page New England repo I am a long-time dark theme user, but I recently developed an interest in coding on a light ...
New
AstonJ
Welcome to our thread for Windows users :smiley: Mac users please use this thread Linux users please use this thread For those who dis...
New
AstonJ
If you have any macOS tips or tricks, or a favourite way of using it, please share :icon_biggrin: For general chat about Macs, please us...
New
NickGnd
Hey :waving_hand: Tidewave has just been announced by José Valim :fire: Watch Tidewave transform Claude Desktop into an agent by runni...
New
borag
I shared an Elixir Architect skill for Claude Code which proves that Elixir is the best LLM friendly language (@josevalim ) https://git...
New
AndyL
Elixir has rapidly changing hex packages, both public and private. For people who use AI Coding Tools (Aider, Cursor, Windsurf, etc.), h...
New
evnp
How do you all feel about the use of AI tools for building Elixir/Phoenix projects, with respect to these topics? Longform context below....
New

Other popular topics Top

William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
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
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
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
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement