Note that there are some explanatory texts on larger screens.

plurals
  1. POExtending language definitions (for code highlighting) in notepad++
    text
    copied!<p>I've been doing development in TWIG lately. It is an html templating language that is very simple and robust.</p> <p>I've set notepad++ to automatically treat .twig files as html. This is ok, but I don't get any syntax highlighting on my twig functions. </p> <p>The twig syntax is incredibly simple (by design) and would be easy to add to notepad++. The problem is, everything I find on this subject is either about creating a new language definition (and I do not want to reinvent the html definition), or modifying the color for existing syntax bits in a language.</p> <p>Is there any way to copy a language definition and then modify it in notepad++? If not, is there any way in notepad++ to add extra syntax bits to an existing language definition?</p> <p><em>edit</em></p> <p>TWIG is an html template language/engine. they syntax for it is the same as html, with the addition of a few open/close tags (specifically {% %}, {{ }}, and {# #}) for control statements. you can read more about it at <a href="http://twig.sensiolabs.org/" rel="noreferrer">the twig website</a></p> <p><em>edit #2</em></p> <p>Based on the answer from Brian Deragon, I have been investigating 3 files. Heres what I've figured out/done so far:</p> <ul> <li>\plugins\APIs\html.xml - Seems to define keywords, for autocomplete. I made a copy of the file named twig.xml</li> <li>langs.model.xml - Again, a list of keywords, with all the languages in 1 XML file. I copied the HTML object and replaced the name and ext parameters with twig.</li> <li>stylers.model.xml - Has a list of different items, and style information (color, bg color, font, etc) for each. I copied the HTML section and changed the name and desc parameters to twig.</li> </ul> <p>Those changes done, I opened up a twig file in notepad++, hoping to see it listed in the language options. Sadly, it has not appeared, leading me to believe that some of this is hard coded (and thus what I want might not be possible).</p> <p>The stylers.model.xml is interesting, though. Each entry has a bunch of items, defined like this:</p> <pre><code>&lt;LexerType name="twig" desc="TWIG" ext=""&gt; &lt;WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" /&gt; &lt;WordsStyle name="COMMENT" styleID="9" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /&gt; &lt;WordsStyle name="TAG" styleID="1" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /&gt; &lt;WordsStyle name="TAGEND" styleID="11" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /&gt; ... &lt;/LexerType&gt; </code></pre> <p>Those seem to be where the styles are defined for the different elements. I can't find anywhere where those elements are defined though. langs.model.xml has a definition for comment start/end, but not for any other delimiters. what I really need is a place to tell notepad++ to treat { } as a delimiter, much like it does for &lt; > now.</p> <p><em>edit #3</em></p> <p>I am also looking at this list of user defined languages for notepad++ <a href="http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=User_Defined_Language_Files" rel="noreferrer">http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=User_Defined_Language_Files</a> User defined languages use a different engine, but i might be able to find one in there that is similar to html enough that I can adapt it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload