   @deactivate: ->
     @disposable.dispose()
 
-  activate: (state) ->
-    atom.workspaceView.command 'simple-flake8:toggle', => @toggle()
-    atom.workspaceView.command 'core:save', =>
+  activate: ->
+    atom.commands.add 'atom-text-editor', 'simple-flake8:toggle', => @toggle()
+    atom.commands.add 'atom-text-editor', 'core:save', =>
       on_save = atom.config.get "simple-flake8.validateOnSave"
       if on_save == true
         @toggle()

      @eventElement = atom.views.getView(atom.workspace)

    filePath = editor.getPath()
    flake filePath, (errors) =>
      error_list = []
      if errors.length == 0


module.exports =
class SimpleFlake8View extends SelectListView
  keyBindings: null
  config:
    flake8Command:
      type: "string"
      default: "flake8"
    ignoreErrors:
      type: "boolean"
      default: false
    mcCabeComplexityThreshold:
      type: "string"
      default: ""
    validateOnSave:
      type: "boolean"
      default: true

  @activate: ->
    view = new SimpleFlake8View
