elixir-editors / elixir-editors/emacs-elixir

.formatter.exs not used

Open
#421 3 comments 0 reactions 0 assignees View on GitHub
mix format
Dominant language
Emacs Lisp
Stars
454
Forks
93
PR merge metrics
No merged PRs in 30d

Description

I'm having this weird problem where `elixir-format` doesn't respect the `.formatter.exs` file in my project's root directory when I follow the settings [here](https://github.com/elixir-editors/emacs-elixir#add-elixir-mode-hook-to-run-elixir-format-on-file-save).

How to reproduce:

1. `mix new` a project and change the generated `.formatter.exs` to be
```elixir
# Used by "mix format"
[
inputs: []
]
```
which should not format anything. Assume the project is located at `~/Projects/test`.

2. Mess with the format of `mix.exs` in some way, and run `mix format` from the project root directory manually to confirm that `mix.exs` doesn't get formatted.

3. Now open `mix.exs` with Emacs, enable `projectile-mode`, and run `elixir-format`. This time `mix.exs` *does* get formatted, although the value of `elixir-format-arguments` is shown to be `("--dot-formatter" "~/Projects/test/.formatter.exs")`.

My `elixir-mode` settings:
```elisp
(use-package elixir-mode
:ensure t
:config
(add-hook 'elixir-format-hook
(lambda () (if (projectile-project-p)
(setq elixir-format-arguments
(list "--dot-formatter"
(concat (locate-dominating-file
buffer-file-name
".formatter.exs")
".formatter.exs")))
(setq elixir-format-arguments nil)))))
```

No matter what I do, the file always gets formatted when I run `elixir-format`. I'm not sure whether I'm configuring things incorrectly or hitting a bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.