greplytix / Hamlbars

Sublime Text 3 Syntax highlighting for .hamlbars files which is a combination of both Haml and Handlebars
MIT License
2 stars 0 forks source link

What language constructs are available #6

Closed anthonykulis closed 9 years ago

anthonykulis commented 9 years ago

This question may be outstanding for a bit. Lets make the assumption the preferred language is python although its doesn't really matter. Is it best to go with a single event loop concept, a mutli-threaded, etc? Is it going to be a state machine? Are we going to keep a cached version of the page or read it on every keystroke, matched keystroke, etc? Think about what is the best way to handle this. Make sure when reviewing other plugins this is in the back of your mind.

anthonykulis commented 9 years ago

@jonlegacy hey, lets try to close this out by dec 20... the date on the milestone

picchietti commented 9 years ago

[DOCUMENTATION]

We should make sure our plugin doesn't run on the main sublime thread for performance reasons.

From a general programming sense we would easily think to tackle this problem by either:

  1. Using one or several very complex regular expressions.
  2. Using a state machine/lexical analyzer to parse through the char's manually.

However, we are using sublime text, its api's, and python, so we are not starting from scratch. Some constructs already exist. To define highlighting and completions for buffers of text we need to find the meaningful areas of text or "scopes". These scopes can then be highlighted or completed.

To break the text buffers into scopes sublime uses the ".tmLanguage" files. It is a plist xml file. It takes regular expressions and scope names and defines a scope for texts that match the regex. Please note that sublime uses Oniguruma style regex instead of the more common perl style.

Snippets can be used with scopes. They search for something within a scope and then work with it, usually inserting or substituting text. This will be useful for auto completion.

Scope text can be colored with themes. This will be useful for text highlighting/colorizing.

Please note:

Useful files (used to implement some of the things discussed above):

Useful python modules to import: