     os = require 'os'
     fs = require 'fs'
     path = require 'path'
-    projectPath = ->
-      atom.project.getPaths()[0]
-    isMixProject = ->
-      fs.existsSync(projectPath() + '/mix.exs')
+    projectPath = (textEditor) ->
+      editorPath = textEditor.getPath()
+      for projectPathCandidate in atom.project.getPaths()
+        if editorPath.indexOf(projectPathCandidate) == 0
+          return projectPathCandidate
+      null
+    isMixProject = (textEditor) ->
+      fs.existsSync(projectPath(textEditor) + '/mix.exs')
     isTestFile = (textEditor) ->
-      relativePath = path.relative(projectPath(), textEditor.getPath())
+      relativePath = path.relative(projectPath(textEditor), textEditor.getPath())
       relativePath.split(path.sep)[0] == 'test'
     isForcedElixirc = =>
       @forceElixirc

    getFilePathDir = (textEditor) ->
      filePath = textEditor.getPath()
      path.dirname(filePath)
    getOpts = ->
      opts =
        cwd: projectPath()
        throwOnStdErr: false
        stream: 'both'
    getDepsPa = (textEditor) ->
      env = if isTestFile(textEditor) then "test" else "dev"
      buildDir = path.join("_build", env, "lib")
      fs.readdirSync(path.join(projectPath(), buildDir)).map (item) ->
        path.join(projectPath(), buildDir, item, "ebin")
    lintElixirc = (textEditor) =>
      elixircArgs = [
        "--ignore-module-conflict", "--app", "mix", "--app", "ex_unit", "-o", os.tmpDir(),
      ]
      elixircArgs.push "-pa", item for item in getDepsPa(textEditor)
      elixircArgs.push textEditor.getPath()
      helpers.exec(@elixircPath, elixircArgs, getOpts())
        .then(handleResult(textEditor))
    lintMix = (textEditor) =>
      helpers.exec(@mixPath, ['compile'], getOpts())
        .then (handleResult(textEditor))

    provider =

      lintOnFly: false
      name: 'Elixir'
      lint: (textEditor) =>
        if isForcedElixirc() or not isMixProject(textEditor) or isExsFile(textEditor)
          lintElixirc(textEditor)
        else
          lintMix(textEditor)
