vim syntax highlighting for glib, gobject, gdk and gtk types

i’ve created a file to enable vim syntax highlighting of glib, gobject, gdk and gtk types.

i handled the base gtypes (gboolean, gpointer, etc) by hand but the rest of them were generated semi-automatically using the following commands:

there are probably some inaccuracies in both directions which could be fixed with better handling but it looks to be pretty good. i considered grepping for ‘get_type’ functions in the symbols list but then you don’t get typedefs for things like callback function types.

# from inside glib source tree
find | grep .h$ | xargs cat | sed -e 'sx[/*].*$xx' |
       tr ' \t' '\n\n' | grep ^G[A-Z][A-Za-z]*$ |
       grep -v '^[A-Z]*$' | sort | uniq > ~/GTypes

# from inside gdk/ directory of gtk source tree
find | grep .h$ | xargs cat | sed -e 'sx[/*].*$xx' |
       tr ' \t' '\n\n' | grep ^Gdk[A-Z][A-Za-z]*$ |
       grep -v '^[A-Z]*$' | sort | uniq > ~/GdkTypes

# from inside gtk/ directory of gtk source tree
find | grep .h$ | xargs cat | sed -e 'sx[/*].*$xx' |
       tr ' \t' '\n\n' | grep ^Gtk[A-Z][A-Za-z]*$ |
       grep -v '^[A-Z]*$' | sort | uniq > ~/GtkTypes

# from ~
cat ~/G*Types | tr '\n' ' ' | fmt -w 60 |
  sed -e 's/^/syn keyword cType /' > gtk-highlight.vim

thanks to tpope on #vim for telling me about ~/.vim and to jdub for ‘fmt’

2 thoughts on “vim syntax highlighting for glib, gobject, gdk and gtk types”

  1. Okay, well, I didn’t know this existed or was even possible with VIM! Thanks a bunch, both of you!

Comments are closed.