diff --git a/lib/interlink.coffee b/lib/interlink.coffee index 1c8e8de..bd9e838 100644 --- a/lib/interlink.coffee +++ b/lib/interlink.coffee @@ -1,10 +1,12 @@ fs = require 'fs-plus' +path = require 'path' {CompositeDisposable} = require 'atom' Utility = require './utility' module.exports = class Interlink constructor: -> + Interlink.loadGrammarSync() @subscriptions = new CompositeDisposable @subscriptions.add atom.commands.add 'atom-workspace', 'nvatom:openInterlink': => Interlink.openInterlink() @subscriptions.add atom.workspace.observeTextEditors (editor) -> @@ -14,6 +16,11 @@ class Interlink destroy: -> @subscriptions.dispose() + @loadGrammarSync: -> + unless atom.grammars.grammarForScopeName('source.gfm.nvatom') + grammarPath = path.join(atom.packages.resolvePackagePath('nvatom'), 'grammars', 'nvatom.cson') + atom.grammars.loadGrammarSync(grammarPath) + @openInterlink: -> editor = atom.workspace.getActiveTextEditor() return unless editor? diff --git a/spec/interlink-spec.coffee b/spec/interlink-spec.coffee index 2b11756..bd8a2f3 100644 --- a/spec/interlink-spec.coffee +++ b/spec/interlink-spec.coffee @@ -19,7 +19,7 @@ describe 'Interlink', -> afterEach -> atom.config.set('nvatom.directory', defaultDirectory) - describe 'when getInerlinkUnderCursor is called', -> + describe 'when getInterlinkUnderCursor is called', -> editor = null describe 'under the note directory', ->