   constructor: (@message) ->
     @name = 'SpecError'
 
-getVimState = (args...) ->
-  [editor, file, callback] = []
-  switch args.length
-    when 1 then [callback] = args
-    when 2 then [file, callback] = args
-
-  waitsForPromise ->
-    atom.packages.activatePackage(packageName)
-
-  waitsForPromise ->
-    file = atom.project.resolvePath(file) if file
-    atom.workspace.open(file).then (e) ->
-      editor = e
-
-  runs ->
-    pack = atom.packages.getActivePackage(packageName)
-    main = pack.mainModule
-    vimState = main.getEditorState(editor)
-    {editorElement} = vimState
-    editorElement.addEventListener 'keydown', (e) ->
-      atom.keymaps.handleKeyboardEvent(e)
-
-    callback(vimState, new VimEditor(vimState))
-
+# Utils
+# -------------------------
 getView = (model) ->
   atom.views.getView(model)
+
+dispatch = (target, command) ->
+  atom.commands.dispatch(target, command)
 
 mockPlatform = (editorElement, platform) ->
   wrapper = document.createElement('div')

toArray = (obj, cond=null) ->
  if _.isArray(cond ? obj) then obj else [obj]

class VimEditor
  constructor: (@vimState) ->
    {@editor, @editorElement} = @vimState

    if mocked
      unmockPlatform(element)

module.exports = {getVimState, getView, dispatch}
