atom/atom — pull request #2700 by benogle (2014-06-20 21:48:10+00:00)
Title: Preload grammars on deserialization

While digging into #2679, I noticed that all files are loaded with the null grammar until the specific grammar is loaded. This creates the issue in #2679, but also makes the editor feel dumpy on reload as there is a sizable chunk of time where it's not colorized.

So this preloads / sync loads the grammars needed by deserialized buffers.

I just serialize the grammar name, and on deserialize, the `TokenizedBuffer` calls `atom.syntax.requestGrammarPreload`, which emits an event, which the relevant package handles and loads its grammars sync. This whole process happens _right_ before the soon-to-be-new TokenizedBuffer chooses its grammar.

The biggest issue is that nowhere do we map grammar names to the name of the package, so I have a shitty hardcoded line in there to do this work until I have a legit solution. Options for solving this issue:

1. on serialize, serialize the name of the package, rather than the grammar name
2. add a package.json field specifying the grammar names that the package provides. Since grammars are not activated right away, I have no other way to read the name of the grammar.

I'm leaning toward 1 because it will be hard to get people to change their package.json's and people will forget to add this field anyway.

What do you guys think about all this?

Will fix #2679 if we decide to go down this route.