sublimelsp / LSP-elixir

Elixir support for Sublime LSP plugin

Home Page:https://lsp.sublimetext.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Formatter config not reliably applied

woylie opened this issue · comments

I don't know whether this is an issue with LSP-elixir or elixir-ls, but the rules in formatter.exs are not reliably applied.

For example, if I have something like this in my formatter.exs:

[
  import_deps: [:ecto],
  # ...
]

Then this is should normally be left as it is:

schema "pets" do
    field :name, :string
end

And this works for a while, but at some point, the LSP will format this on save without regarding the formatter config and add parentheses:

schema "pets" do
   field(:name, :string)
end

This has been pretty unreliable before, and the solution was always to restart Sublime, until it occurs again, but it has gotten worse to the point where I can save one or two times until it messes up all the formatting, which means it is impossible for me to work with format-on-save. Please let me know whether you think this is an issue with this package or the LSP.

Running mix format from the terminal works fine, in case you're wondering.

LSP 1.17.0
LSP-elixir 0.5.0
Sublime 4126
Elixir 1.13.4 (compiled with Erlang/OTP 25)

It's an Elixir LS (or dialyzer rather) issue. When changes are still compiling, the configs are sometimes reloaded / not fully loaded. I used to see it quite often but not as much now since I got a new computer (that is more recent and quite muscular - and compiles most of things instantly). So you could also say it's a machine issue... :)

When you see it occurring, I normally just ctrl+Z and wait a bit for it to finish compiling / recompiling. Then save again. That normally does the trick. However, as I said before I haven't seen this in a while now, not sure if it still works the way like it used to.

My machine isn't that bad... Anyway, thanks for the hint!

Here's the upstream issue: elixir-lsp/elixir-ls#526

Thanks Jason 😀