mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
Add NullGrammar to obviate synchronous load of text grammar on start
It's also an extremely simple grammar, so we'll do less work to initially tokenize open buffers before loading their real grammars.
This commit is contained in:
parent
a2f72882d7
commit
2416ff19a4
@ -41,12 +41,6 @@ _.extend atom,
|
||||
packageStates[pack.name] = @atomPackageStates[pack.name]
|
||||
packageStates
|
||||
|
||||
loadTextPackage: ->
|
||||
textPackagePath = _.find @getPackagePaths(), (path) -> fs.base(path) is 'text.tmbundle'
|
||||
pack = Package.build(textPackagePath)
|
||||
@loadedPackages.push(pack)
|
||||
pack.load(sync: true)
|
||||
|
||||
loadPackages: ->
|
||||
textMatePackages = []
|
||||
paths = @getPackagePaths().filter (path) -> fs.base(path) isnt 'text.tmbundle'
|
||||
|
9
src/app/null-grammar.coffee
Normal file
9
src/app/null-grammar.coffee
Normal file
@ -0,0 +1,9 @@
|
||||
Token = require 'token'
|
||||
|
||||
module.exports =
|
||||
class NullGrammar
|
||||
name: "Null Grammar"
|
||||
scopeName: 'text.plain.null-grammar'
|
||||
|
||||
tokenizeLine: (line) ->
|
||||
{ tokens: [new Token(value: line, scopes: ['null-grammar.text.plain'])] }
|
@ -4,6 +4,7 @@ Specificity = require 'specificity'
|
||||
{$$} = require 'space-pen'
|
||||
fs = require 'fs-utils'
|
||||
EventEmitter = require 'event-emitter'
|
||||
NullGrammar = require 'null-grammar'
|
||||
|
||||
module.exports =
|
||||
class Syntax
|
||||
@ -14,6 +15,7 @@ class Syntax
|
||||
@globalProperties = {}
|
||||
@scopedPropertiesIndex = 0
|
||||
@scopedProperties = []
|
||||
@nullGrammar = new NullGrammar
|
||||
|
||||
addGrammar: (grammar) ->
|
||||
@grammars.push(grammar)
|
||||
@ -22,7 +24,7 @@ class Syntax
|
||||
@grammarsByScopeName[grammar.scopeName] = grammar
|
||||
|
||||
selectGrammar: (filePath, fileContents) ->
|
||||
return @grammarsByFileType["txt"] unless filePath
|
||||
return @grammarsByFileType["txt"] ? @nullGrammar unless filePath
|
||||
|
||||
extension = fs.extension(filePath)?[1..]
|
||||
if filePath and extension.length == 0
|
||||
@ -31,7 +33,7 @@ class Syntax
|
||||
@grammarByFirstLineRegex(filePath, fileContents) or
|
||||
@grammarsByFileType[extension] or
|
||||
@grammarByFileTypeSuffix(filePath) or
|
||||
@grammarsByFileType["txt"]
|
||||
@grammarsByFileType["txt"] ? @nullGrammar
|
||||
|
||||
grammarByFileTypeSuffix: (filePath) ->
|
||||
for fileType, grammar of @grammarsByFileType
|
||||
|
@ -52,7 +52,6 @@ window.startup = ->
|
||||
|
||||
handleWindowEvents()
|
||||
config.load()
|
||||
atom.loadTextPackage()
|
||||
keymap.loadBundledKeymaps()
|
||||
atom.loadThemes()
|
||||
atom.loadPackages()
|
||||
|
Loading…
Reference in New Issue
Block a user