JakeBecker / elixir-ls

A frontend-independent IDE "smartness" server for Elixir. Implements the JSON-based "Language Server Protocol" standard and provides debugger support via VS Code's debugger protocol.
Apache License 2.0
843 stars 52 forks source link

The `import_deps` option in .formatter.exs is ignored #114

Closed alco closed 6 years ago

alco commented 6 years ago

Environment

I've created a dummy project with mix new fmt_test and added {:plug, "~> 1.0"} in mix.exs. Contents of my .formatter.exs at the root of the project:

# Used by "mix format"
[
  inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"],
  import_deps: [:plug]
]

Contents of the lib/fmt_test.ex file:

defmodule FmtTest do
  use Plug.Builder

  plug :foobar

  def foobar(conn, _opts) do
    conn
  end
end

When I navigate to the project root in my shell and run mix format, it leaves the code unchanged. However, invoking the Format document command in VSCode changes the 4th line to plug(:foobar).

I think this is related to the caveat mentioned in the docs for mix format:

  • :import_deps (a list of dependencies as atoms) - specifies a list of dependencies whose formatter configuration will be imported. When specified, the formatter should run in the same directory as the mix.exs file that defines those dependencies. See the “Importing dependencies configuration” section below for more information.
JakeBecker commented 6 years ago

This works if you're using Elixir >= 1.6.5. See https://github.com/JakeBecker/elixir-ls/issues/67

alco commented 6 years ago

Oops, sorry I missed that.