Sudden issues with ElixirLS : "Formatter plugin Phoenix.LiveView.HTMLFormatter cannot be found"

I have an issue with ElixirLS in Nvim. This started after upgrading oh_my_zsh and asdf (macos + homebrew). It seems that asdf plugin for omz is out of date. In any case - everything works correctly when running as cli commands. But in nvim, this started to happen:

LSP[elixirls] Unable to find formatter for /Users/xx/project/lib/project_web/endpoint.ex: "** (M
ix.Error) Formatter plugin Phoenix.LiveView.HTMLFormatter cannot be found\n    (mix 1.18.1) lib/mix.ex:613: Mix.raise/
2\n    (language_server 0.24.1) lib/language_server/mix_tasks/format.ex:302: anonymous fn/2 in Mix.Tasks.ElixirLSForma
t.load_plugins/1\n    (elixir 1.18.1) lib/enum.ex:2546: Enum.\"-reduce/3-lists^foldl/2-0-\"/3\n    (language_server 0.
24.1) lib/language_server/mix_tasks/format.ex:299: Mix.Tasks.ElixirLSFormat.load_plugins/1\n    (language_server 0.24.
1) lib/language_server/mix_tasks/format.ex:362: Mix.Tasks.ElixirLSFormat.formatter_for_file/2\n    (language_server 0.
24.1) lib/language_server/source_file.ex:277: ElixirLS.LanguageServer.SourceFile.formatter_for/3\n    (language_server
 0.24.1) lib/language_server/providers/formatting.ex:14: ElixirLS.LanguageServer.Providers.Formatting.format/4\n    (l
anguage_server 0.24.1) lib/language_server/server.ex:1270: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_req
uest_async/2\n"
[LSP][elixirls] timeout
"lib/project_web/endpoint.ex" 48L, 1357B written

What I did try:

  • “asdf reshim”, etc.
  • reinstalling asdf and reinstalling plugins
  • updating plugins in Nvim (using Lazy)
  • after removing “asdf” plugin from oh my zsh, added paths to asdf manually (which is why everything works outside of nvim):
# this before omz compinit
fpath=(${ASDF_DATA_DIR:-$HOME/.asdf}/completions $fpath)
autoload -Uz compinit && compinit
# and this as last entry
export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"

Of course all the projects (this happens universally on any elixir project) have the correct .formatter.exs:

[
  import_deps: [:phoenix],
  plugins: [Phoenix.LiveView.HTMLFormatter],
  inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}"]
]

Luckily, syntax errors and highlighting still works inside the editor - it only the pre-buf-write formatter that fails. There is no specific LSP config in nvim - just defaults:

      ...
      local servers = {
        ...
        elixirls = {},
        ...
      }
      ...

Just for reference, the versions:

❯ asdf list
elixir
 *1.18.1-otp-27
erlang
 *27.2
  27.2.2

I would highly appreciate if somebody could point me in the right direction. This is not an Elixir error per-se, but elixirls/nvim combination, and is for sure something very trivial - but as all of us know, the “a critical tool suddenly stops working” issues while working on a project with tight deadline are the most frustrating.

Did you try removing the _build and .elixir_ls folders?

I had this a couple of days ago but in vscode on my Windows machine. Blowing away those folders resolved it.

So I tried removing the _build folder - but it didn’t change anything.

But then - deleting .elixir_ls in the project seems to have helped on the issue. This was even one of the things that was mentioned in another post here with similar issue, so I guess I should have also tried this. As a consequence of this, I have added .elixir_ls to .gitignore in case there are some local versionings deps that other devs might overwrite.

Thank you for taking time to answer this. I expected it was very trivial.

1 Like