Adding new syntax highlight is rather a simple task (assuming the desired lexer exists in the Scintilla stack).

When creating a new lexer, it is best to start from an existing one. If you are on Linux/Mac, copy one of the existing lexers from ~/.codelite/lexers/Default/ and rename it (on Windows, the lexers are under C:\Program Files\CodeLite\lexers\).

Open the file in your favourite text editor, and start modifying it.

First, rename the "Name" attribute of the lexer to fit your new lexer.

 <?xml version="1.0" encoding="UTF-8"?>
 <Lexer Name="MyLexer" Id="76">

The lexer's "Id" property must exist. Below is the list of available lexers and their respective IDs:

  • wxSCI_LEX_CONTAINER 0
  • wxSCI_LEX_NULL 1
  • wxSCI_LEX_PYTHON 2
  • wxSCI_LEX_CPP 3
  • wxSCI_LEX_HTML 4
  • wxSCI_LEX_XML 5
  • wxSCI_LEX_PERL 6
  • wxSCI_LEX_SQL 7
  • wxSCI_LEX_VB 8
  • wxSCI_LEX_PROPERTIES 9
  • wxSCI_LEX_ERRORLIST 10
  • wxSCI_LEX_MAKEFILE 11
  • wxSCI_LEX_BATCH 12
  • wxSCI_LEX_XCODE 13
  • wxSCI_LEX_LATEX 14
  • wxSCI_LEX_LUA 15
  • wxSCI_LEX_DIFF 16
  • wxSCI_LEX_CONF 17
  • wxSCI_LEX_PASCAL 18
  • wxSCI_LEX_AVE 19
  • wxSCI_LEX_ADA 20
  • wxSCI_LEX_LISP 21
  • wxSCI_LEX_RUBY 22
  • wxSCI_LEX_EIFFEL 23
  • wxSCI_LEX_EIFFELKW 24
  • wxSCI_LEX_TCL 25
  • wxSCI_LEX_NNCRONTAB 26
  • wxSCI_LEX_BULLANT 27
  • wxSCI_LEX_VBSCRIPT 28
  • wxSCI_LEX_BAAN 31
  • wxSCI_LEX_MATLAB 32
  • wxSCI_LEX_SCRIPTOL 33
  • wxSCI_LEX_ASM 34
  • wxSCI_LEX_CPPNOCASE 35
  • wxSCI_LEX_FORTRAN 36
  • wxSCI_LEX_F77 37
  • wxSCI_LEX_CSS 38
  • wxSCI_LEX_POV 39
  • wxSCI_LEX_LOUT 40
  • wxSCI_LEX_ESCRIPT 41
  • wxSCI_LEX_PS 42
  • wxSCI_LEX_NSIS 43
  • wxSCI_LEX_MMIXAL 44
  • wxSCI_LEX_CLW 45
  • wxSCI_LEX_CLWNOCASE 46
  • wxSCI_LEX_LOT 47
  • wxSCI_LEX_YAML 48
  • wxSCI_LEX_TEX 49
  • wxSCI_LEX_METAPOST 50
  • wxSCI_LEX_POWERBASIC 51
  • wxSCI_LEX_FORTH 52
  • wxSCI_LEX_ERLANG 53
  • wxSCI_LEX_OCTAVE 54
  • wxSCI_LEX_MSSQL 55
  • wxSCI_LEX_VERILOG 56
  • wxSCI_LEX_KIX 57
  • wxSCI_LEX_GUI4CLI 58
  • wxSCI_LEX_SPECMAN 59
  • wxSCI_LEX_AU3 60
  • wxSCI_LEX_APDL 61
  • wxSCI_LEX_BASH 62
  • wxSCI_LEX_ASN1 63
  • wxSCI_LEX_VHDL 64
  • wxSCI_LEX_CAML 65
  • wxSCI_LEX_BLITZBASIC 66
  • wxSCI_LEX_PUREBASIC 67
  • wxSCI_LEX_HASKELL 68
  • wxSCI_LEX_PHPSCRIPT 69
  • wxSCI_LEX_TADS3 70
  • wxSCI_LEX_REBOL 71
  • wxSCI_LEX_SMALLTALK 72
  • wxSCI_LEX_FLAGSHIP 73
  • wxSCI_LEX_CSOUND 74
  • wxSCI_LEX_FREEBASIC 75
  • wxSCI_LEX_INNOSETUP 76
  • wxSCI_LEX_OPAL 77
  • wxSCI_LEX_SPICE 78
  • wxSCI_LEX_D 79
  • wxSCI_LEX_CMAKE 80
  • wxSCI_LEX_GAP 81
  • wxSCI_LEX_PLM 82
  • wxSCI_LEX_PROGRESS 83
  • wxSCI_LEX_ABAQUS 84
  • wxSCI_LEX_ASYMPTOTE 85
  • wxSCI_LEX_R 86
  • wxSCI_LEX_MAGIK 87
  • wxSCI_LEX_POWERSHELL 88

Next, edit the keywords set. If you don't need more than one keyword set, you can leave the other keywords empty.
For more information about which lexer requires more than one keyword set, refer to http://scintilla.org/

 <KeyWords0>my space delimited key word set</KeyWords0>
 <KeyWords1></KeyWords1>
 <KeyWords2></KeyWords2>
 <KeyWords3></KeyWords3>

Edit the file extensions so CodeLite can assign the new lexer to them:

 <Extensions>*.ext;*.ext2;*.lal</Extensions>

Last, the 'properties' section. Each lexer has several lexical states, and each of those can be assigned a different visual style (for example, in the C++ lexer, a comment is a state, so you might want to assign it a different colour and font; a preprocessor line is also a state which you would usually choose to colour differently; and so on and so forth).

Each of the above lexers, has a predefined state (to see the full list of states per lexer, search this Scintilla header file: wxscintilla.h)

For example, the C++ lexer has the following states (scintilla's states are numbered from 0-n) - it is recommended to leave the 'Face' property empty; CodeLite will choose one for you from the FIXED WIDTH font family:

 <Property Id="0" Name="Default" Bold="no" Face="" Colour="#808080" BgColour="#FFFFFF" Size="9"/>
 <Property Id="1" Name="Comment" Bold="no" Face="" Colour="#008000" BgColour="#FFFFFF" Size="9"/>
 <Property Id="2" Name="Keyword" Bold="no" Face="" Colour="#0000FF" BgColour="#FFFFFF" Size="9"/>
 <Property Id="3" Name="Parameter" Bold="no" Face="" Colour="#800040" BgColour="#FFFFFF" Size="9"/>
 <Property Id="4" Name="Section" Bold="no" Face="" Colour="#400000" BgColour="#C8C891" Size="9"/>
 <Property Id="5" Name="Preprocessor" Bold="no" Face="" Colour="#808080" BgColour="#FFFFFF" Size="9"/>
 <Property Id="6" Name="Preprocessor (inline)" Bold="no" Face="" Colour="#808080" BgColour="#FFFFFF" Size="9"/>
 <Property Id="7" Name="Pascal comment" Bold="no" Face="" Colour="#008000" BgColour="#FFFFFF" Size="9"/>
 <Property Id="8" Name="Pascal keyword" Bold="no" Face="" Colour="#0000FF" BgColour="#FFFFFF" Size="9"/>
 <Property Id="9" Name="User defined keyword" Bold="no" Face="" Colour="#800080" BgColour="#FFFFFF" Size="9"/>
 <Property Id="10" Name="Double quoted string" Bold="no" Face="" Colour="#808080" BgColour="#FFFFFF" Size="9"/>
 <Property Id="11" Name="Single quoted string" Bold="no" Face="" Colour="#800000" BgColour="#FFFFFF" Size="9"/>

Where:

  • Id - the lexer's state Id as exist in wxscintilla.h header file
  • Name - any name
  • Bold - yes / no
  • Face - a font name (you can leave this one empty)
  • Colour - accepts format of HTML, "rgb(r, g, b)" or colour name ("BLUE", "GREEN" etc)
  • BgColour - background colour for the state
  • Size - font size in pixels

Ids -1 to -3 and 33 to 35, and 37-38 are special; they should be in every new lexer you add:

 <Property Id="-1" Name="Fold Margin" Bold="no" Face="" Colour="#FFFFFF" BgColour="#D0D0D0" Size="9"/>
 <Property Id="-2" Name="Text Selection" Bold="no" Face="" Colour="#000000" BgColour="#C0C0C0" Size="9"/>
 <Property Id="-3" Name="Caret Colour" Bold="no" Face="" Colour="#000000" BgColour="#000000" Size="9"/>
 <Property Id="33" Name="Line Numbers" Bold="no" Face="" Colour="#004080" BgColour="#FFFFFF" Size="9"/>
 <Property Id="34" Name="Brace match" Bold="no" Face="" Colour="#000000" BgColour="#8BBF86" Size="9"/>
 <Property Id="35" Name="Brace bad match" Bold="no" Face="" Colour="#000000" BgColour="#FF0000" Size="9"/>
 <Property Id="37" Name="Indent Guide" Bold="no" Italic="no" Underline="no" Face="" Colour="#C0C0C0" BgColour="#FFFFFF" Size="9"/>
 <Property Id="38" Name="Calltip" Bold="no" Italic="no" Underline="no" Face="" Colour="#C0C0C0" BgColour="#FFFFFF" Size="9"/>