GLSL shaders share a lot in common with the C language, and Gedit can syntax highlight C/C++ and a host of other languages – so why not GLSL shaders? Here’s a simple way to make it happen…
1.) Gedit uses gtksourceview for its syntax highlighting rules – so find out where that’s located on your distro with the following:
locate gtksourceview | grep /c.lang
Once you’ve got the location of the c.lang file, navigate there in the bash (on Ubuntu it’s in /usr/share/gtksourceview-2.0/language-specs).
2.) Make a copy of the c.lang file in case you accidentally stuff it up (optional, but better safe than sorry):
sudo cp c.lang c.lang.ORIG
3.) Open the file with your text editor of choice and modify the c.lang file to add in additional file extensions which should be syntax highlighted as per the c.lang definitions:
gksudo gedit ./c.lang
A couple of lines into the file (after the comments at the top) you’ll see the following:
Assuming you’re ending your vertex shaders with .vp and your fragment shaders with .fp (if you’re using .vert and .frag or such just substitute appropriately), change the line to read:
Save it, close gedit, and open a .vp or .fp file with Gedit – syntax highlighty goodness is rightfully yours. Of course, this is normal C highlighting, not true GLSL highlighting – but it’s a good start.
If you wanted to add things like vec3, uniform etc. then you can find the following sections in the c.lang file and add ’em in yourself:
<context id="keywords" style-ref="keyword" class="keyword"> <context id="types" style-ref="type" class="type">