mtdk

mtdk

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.

Marked As Solved

cmo

cmo

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.

Also Liked

mtdk

mtdk

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.

Where Next?

Popular in Questions Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
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
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
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
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement