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.

Where Next?

Popular in Dev Env & Tools Top

AstonJ
Do we have any frequent travellers or digital nomads here? If so where have you been and do you have any tips to share? (Particularly in...
New
funboy
Hi, I built a small utility tool mainly for running test partitions, generating coverage reports, and rerunning failed tests across all ...
New
sodapopcan
I just placed on an order for my first mechanical watch since I last wore one in my mid 20s which was… oh boy, technically decadeS ago (t...
New
jpease
If it’s useful to anyone, here’s a tiny nvim plugin (jpease/hex-outdated.nvim) that shows drift between your mix.exs and packages on hex....
New
jswanner
I was about to reply to Why doesn’t Phoenix use Conventional Commit prefixes? - #41 by sodapopcan with some git aliases that I use for th...
New
mhanberg
Hi y’all! I have started a dedicated Elixir plugin for Neovim. It is still early days, but please check it! GitHub - elixir-tools/elixir...
New
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
How fast is your internet connection? (And how much do you pay?) You can test via www.speedtest.net and to embed results into your post...
New
Nezteb
I frequently switch between ElixirLS, Lexical, and Next LS in order to test each out and compare/contrast. I decided to create a brief fe...
New
AstonJ
Welcome to our thread for Linux users :smiley: Mac users please use this thread Windows users please use this thread For those who dis...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
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 30877 112
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
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
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
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement