Fl4m3Ph03n1x

Fl4m3Ph03n1x

Format elixir on save VIM

Background

I am using VIM and I would like for vim to run mix format on save (:w).
However, I cannot find anything that does this.

Does someone know a plugin for this?
How many of you use VIM?

Marked As Solved

pmangalakader

pmangalakader

To answer your original problem:

autocmd BufWritePre *.ex,*.exs execute "!mix format %"

I use coc-elixir along coc.nvim… which provides coc-settings.json that can be used to configure formatting options.

https://github.com/elixir-lsp/coc-elixir

https://github.com/neoclide/coc.nvim

Also Liked

stevensonmt

stevensonmt

According to this the autocmd event should be BufWritePre.

Hermanverschooten

Hermanverschooten

I use LunarVim, comes with language-server, etc built-in.
Formatting is also included.
Easiest VIM-setup in years.

hauleth

hauleth

Autocommand BufPreWrite would do. Just remember to wrap it in augroup.

Last Post!

thenrio

thenrio

I use nvim, with coc and elixir-ls.

I was not using format on save for elixir files (not sure why?), just turned it on, with coc, with Format elixir files on save · thenrio/dotfiles@264a9f9 · GitHub.

Where Next?

Popular in Questions Top

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
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
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
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
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
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

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
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
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

We're in Beta

About us Mission Statement