 
   # Get current editor
   editor = atom.workspace.getActiveEditor()
-  # Get current Atom editor configuration
   isSelection = !!editor.getSelectedText()
-  softTabs = editor.softTabs
-  tabLength = editor.getTabLength()
-  editorOptions =
-    indent_size: (if softTabs then tabLength else 1)
-    indent_char: (if softTabs then " " else "\t")
-    indent_with_tabs: not softTabs
-  configOptions = getConfigOptionsFromSettings(languages)
-
   # Get editor path and configurations for paths
   editedFilePath = editor.getPath()
-
-  # Get configuration in User's Home directory
-  userHome = getUserHome()
-  # FAKEFILENAME forces `path` to treat as file path and it's parent directory
-  # is the userHome. See implementation of findConfig
-  # and how path.dirname(DIRECTORY) returns the parent directory of DIRECTORY
-  homeOptions = getConfig(path.join(userHome,"FAKEFILENAME"), false)
-
-  if editedFilePath?
-    # Handle EditorConfig options
-    # http://editorconfig.org/
-    editorconfig ?= require('editorconfig');
-    editorConfigOptions = editorconfig.parse(editedFilePath);
-    # Transform EditorConfig to Atom Beautify's config structure and naming
-    if editorConfigOptions.indent_style is 'space'
-      editorConfigOptions.indent_char = " "
-      # if (editorConfigOptions.indent_size)
-      #   editorConfigOptions.indent_size = config.indent_size
-    else if editorConfigOptions.indent_style is 'tab'
-      editorConfigOptions.indent_char = "\t"
-      editorConfigOptions.indent_with_tabs = true
-      if (editorConfigOptions.tab_width)
-          editorConfigOptions.indent_size = editorConfigOptions.tab_width
-
-    # Get all options in configuration files from this directory upwards to root
-    projectOptions = []
-    p = path.dirname(editedFilePath)
-    # Check if p is root (top directory)
-    while p isnt path.resolve(p,"../")
-      # Get config for p
-      pf = path.join(p, "FAKEFILENAME")
-      pc = getConfig(pf, false)
-      # Add config for p to project's config options
-      projectOptions.push(pc)
-      # console.log p, pc
-      # Move upwards
-      p = path.resolve(p,"../")
-  else
-    editorConfigOptions = {}
-    projectOptions = []
-
-  # Combine all options together
-  allOptions = [
-    editorOptions
-    configOptions
-    homeOptions
-    editorConfigOptions
-  ]
-  allOptions = allOptions.concat(projectOptions)
+  # Get all options
+  allOptions = options.getOptionsForPath(editedFilePath, editor)
 
   # Get current editor's text
   text = undefined

PlainMessageView = null
editorconfig = null
$ = null

#MessageView = require "./message-view"
findFileResults = {}

# CLI
getUserHome = ->
  process.env.HOME or process.env.HOMEPATH or process.env.USERPROFILE

# function cleanOptions(data, types) {
#   nopt.clean(data, types);

    editor.addCursorAtBufferPosition bufferPosition
  return

beautify = ({onSave})->
  path ?= require("path")
  MessagePanelView ?= require('atom-message-panel').MessagePanelView
