-{ CompositeDisposable, Disposable } = require 'atom'
-path = require 'path'
-
 module.exports =
   config: require './config'
 
   activate: ->
+    { CompositeDisposable } = require 'atom'
     @disposables = new CompositeDisposable
     @activated = false
     global.atom_latex = this

      'atom-latex:tools-backquote': () => @latex.provider.syntax.backquote()
      'atom-latex:tools-doublequote': () => @latex.provider.syntax.doublequote()

    @disposables.add atom.workspace.observeTextEditors (editor) =>
      @disposables.add editor.onDidSave () =>
        if atom.config.get('atom-latex.build_after_save') and \
            editor.buffer.file?.path and \
            path.extname(editor.buffer.file?.path) == '.tex'
          @latex.builder.build()

  deactivate: ->
    return @disposables.dispose()

  provide: ->
    if !@provider?

      @status = new Status
      @disposables.add @status
    @status.attach statusBar
    { Disposable } = require 'atom'
    return new Disposable( => @status.detach())

class AtomLaTeX
  constructor: ->
    { CompositeDisposable } = require 'atom'
    @disposables = new CompositeDisposable
    Builder = require './builder'
    Cleaner = require './cleaner'
