Skip to content

obmarg/mix-format.el

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elixir-format

Emacs package to format your Elixir code.

Setup

Customize the elixir and mix pathes

In Emacs, run following command to customize option

M-x customize-option

Customize-variable: elixir-format-elixir-path

and set your elixir executable path there. After that run:

M-x customize-option

Customize-variable: elixir-format-mix-path

and set your mix executable path there.

Your machine's elixir and mix executable paths can be found with which command as shown below

$ which mix
/usr/local/bin/mix

Usage

;; require from Emacs
(require elixir-format)

;; Use it
M-x elixir-format

Add elixir-mode hook to run mix format on file save

;; elixir-mode hook
(add-hook 'elixir-mode-hook
          (lambda () (add-hook 'before-save-hook elixir-format-before-save)))

To use a .formatter.exs you can either set elixir-format-arguments globally to a path like this:

(setq elixir-format-arguments (list "--dot-formatter" "/path/to/.formatter.exs"))

or you set elixir-format-arguments in a hook like this:

(add-hook elixir-format-hook '(lambda ()
                                 (if (projectile-project-p)
                                     (setq elixir-format-arguments (list "--dot-formatter" (concat (projectile-project-root) "/.formatter.exs")))
                                   (setq elixir-format-arguments nil))))

In this example we use Projectile to get the project root and set elixir-format-arguments accordingly.

Contribute

Feel free to contribute

Author

(anil@anilwadghule.com) ; anil wadghule

About

Emacs package to format Elixir code in Emacs with elixir-mode

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Emacs Lisp 100.0%