Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatter config not reliably applied #30

Closed
woylie opened this issue Aug 23, 2022 · 4 comments
Closed

Formatter config not reliably applied #30

woylie opened this issue Aug 23, 2022 · 4 comments
Labels

Comments

@woylie
Copy link

woylie commented Aug 23, 2022

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)

@princemaple
Copy link
Collaborator

princemaple commented Aug 23, 2022

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.

@woylie
Copy link
Author

woylie commented Aug 23, 2022

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

@axelson
Copy link

axelson commented Aug 23, 2022

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

@princemaple
Copy link
Collaborator

Thanks Jason 😀

@princemaple princemaple pinned this issue May 25, 2023
@princemaple princemaple closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants