1 {Disposable, CompositeDisposable} = require 'event-kit'
2 StatusBarManager = require './status-bar-manager'
3 GlobalVimState = require './global-vim-state'
4 VimState = require './vim-state'
5 settings = require './settings'
8 config: settings.config
11 @disposables = new CompositeDisposable
12 @globalVimState = new GlobalVimState
13 @statusBarManager = new StatusBarManager
16 @vimStatesByEditor = new WeakMap
18 @disposables.add atom.workspace.observeTextEditors (editor) =>
19 return if editor.isMini() or @vimStatesByEditor.get(editor)
21 vimState = new VimState(
22 atom.views.getView(editor),
27 @vimStates.add(vimState)
28 @vimStatesByEditor.set(editor, vimState)
29 vimState.onDidDestroy => @vimStates.delete(vimState)
31 @disposables.add new Disposable =>
32 @vimStates.forEach (vimState) -> vimState.destroy()
35 @disposables.dispose()
40 getEditorState: (editor) ->
41 @vimStatesByEditor.get(editor)
43 consumeStatusBar: (statusBar) ->
44 @statusBarManager.initialize(statusBar)
45 @statusBarManager.attach()
46 @disposables.add new Disposable =>
47 @statusBarManager.detach()
50 getGlobalState: @getGlobalState.bind(this)
51 getEditorState: @getEditorState.bind(this)