mirror of
https://github.com/wassname/nvatom.git
synced 2026-06-27 16:10:36 +08:00
Load nvatom grammar on atom
This commit is contained in:
@@ -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?
|
||||
|
||||
@@ -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', ->
|
||||
|
||||
Reference in New Issue
Block a user