

GitHub - anildigital/mix-format.el: Emacs package to format Elixir code in Emacs...
source link: https://github.com/anildigital/mix-format.el
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
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
([email protected]) ; anil wadghule
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK