elixir-lsp / vscode-elixir-ls

Elixir language support and debugger for VS Code, powered by ElixirLS.
https://marketplace.visualstudio.com/items?itemName=JakeBecker.elixir-ls
MIT License
545 stars 106 forks source link

Question about Support for Trailing Commas in ElixirLS Formatter #423

Closed Putinspudding closed 5 months ago

Putinspudding commented 5 months ago

Environment

Troubleshooting

Hi there,I've noticed that the formatter in ElixirLS doesn’t support trailing commas in lists, maps, or function definitions. When using so,it will be auto trimed when saving. Something like when I write this:

  def test do
    {
      :foo,
      :bar,
    }
  end

It will auto formatted as:

  def test do
    {
      :foo,
      :bar
    }
  end

Trailing commas can make diffs cleaner and code maintenance easier. Is there any chance this feature or an settings option could be added in a future update?

lukaszsamson commented 5 months ago

I do like trailing commas but the upstream elixir formatter does not support it and there is currently no plan. See https://github.com/elixir-lang/elixir/issues/13320 and https://github.com/elixir-lang/elixir/pull/7689#issuecomment-389588019. You can try your luck with https://github.com/marcandre/freedom_formatter but I never tested it with elixir-ls