 
           @editorSaveSubscriptions[editor.id] = buffer.onWillSave =>
             buffer.transact =>
-              @formatJavascript(editor)
+              @format(state)
 
           @editorCloseSubscriptions[editor.id] = buffer.onDidDestroy =>
             @editorSaveSubscriptions[editor.id].dispose()

      return

    grammar = editor.getGrammar()?.scopeName

    if grammar is 'source.json' or grammar is 'source.js'
      @formatJavascript editor
    else
      notification = new FileTypeNotSupportedView(state)
      atom.workspaceView.append(notification)


    if @selectionsAreEmpty editor
      editor.setText(jsbeautify(editor.getText(), opts))

    else
      for selection in editor.getSelections()
        selection.insertText(jsbeautify(selection.getText(), opts), {select:true})
