From a9f9f6a77ef92788ed5755099ff409fd4674ff27 Mon Sep 17 00:00:00 2001 From: Nicolas Gagliani Date: Fri, 19 Feb 2016 14:03:49 +0100 Subject: [PATCH] Should have a much better startup time Trades the startup time for slower execution of the first command --- lib/idris-controller.coffee | 16 -------------- lib/language-idris.coffee | 44 ++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/lib/idris-controller.coffee b/lib/idris-controller.coffee index d9dd42c..375353c 100644 --- a/lib/idris-controller.coffee +++ b/lib/idris-controller.coffee @@ -10,22 +10,6 @@ editorHelper = require './utils/editor' class IdrisController - getCommands: -> - 'language-idris:type-of': @runCommand @getTypeForWord - 'language-idris:docs-for': @runCommand @getDocsForWord - 'language-idris:case-split': @runCommand @doCaseSplit - 'language-idris:add-clause': @runCommand @doAddClause - 'language-idris:make-with': @runCommand @doMakeWith - 'language-idris:make-lemma': @runCommand @doMakeLemma - 'language-idris:make-case': @runCommand @doMakeCase - 'language-idris:holes': @runCommand @showHoles - 'language-idris:proof-search': @runCommand @doProofSearch - 'language-idris:typecheck': @runCommand @typecheckFile - 'language-idris:print-definition': @runCommand @printDefinition - 'language-idris:stop-compiler': @stopCompiler - 'language-idris:open-repl': @runCommand @openREPL - 'language-idris:apropos': @runCommand @apropos - isIdrisFile: (uri) -> uri?.match? /\.idr$/ diff --git a/lib/language-idris.coffee b/lib/language-idris.coffee index 07aa7ca..94e80fe 100644 --- a/lib/language-idris.coffee +++ b/lib/language-idris.coffee @@ -1,7 +1,6 @@ -IdrisController = require './idris-controller' { CompositeDisposable } = require 'atom' url = require 'url' -{ IdrisPanel } = require './views/panel-view' +IdrisPanel = undefined module.exports = config: @@ -24,9 +23,7 @@ module.exports = description: 'Enable ligatures in the various idris panels' activate: -> - @controller = new IdrisController - - subscription = atom.commands.add 'atom-text-editor[data-grammar~="idris"]', @controller.getCommands() + subscription = atom.commands.add 'atom-text-editor[data-grammar~="idris"]', @getCommands() @subscriptions = new CompositeDisposable @subscriptions.add subscription @@ -38,8 +35,45 @@ module.exports = return unless protocol is 'idris:' + if !IdrisPanel + { IdrisPanel } = require './views/panel-view' + + @loadController() new IdrisPanel @controller, host + loadController: -> + if !@controller + IdrisController = require './idris-controller' + @controller = new IdrisController + + runCommand: (command) -> + that = this + + (args) -> + if !that.controller + that.loadController() + + if command == 'stopCompiler' + that.controller.stopCompiler() + else + that.controller.runCommand(that.controller[command])(args) + + getCommands: () -> + 'language-idris:type-of': @runCommand 'getTypeForWord' + 'language-idris:docs-for': @runCommand 'getDocsForWord' + 'language-idris:case-split': @runCommand 'doCaseSplit' + 'language-idris:add-clause': @runCommand 'doAddClause' + 'language-idris:make-with': @runCommand 'doMakeWith' + 'language-idris:make-lemma': @runCommand 'doMakeLemma' + 'language-idris:make-case': @runCommand 'doMakeCase' + 'language-idris:holes': @runCommand 'showHoles' + 'language-idris:proof-search': @runCommand 'doProofSearch' + 'language-idris:typecheck': @runCommand 'typecheckFile' + 'language-idris:print-definition': @runCommand 'printDefinition' + 'language-idris:stop-compiler': @runCommand 'stopCompiler' + 'language-idris:open-repl': @runCommand 'openREPL' + 'language-idris:apropos': @runCommand 'apropos' + deactivate: -> @subscriptions.dispose() this.controller.destroy()