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’
This already exists.
See http://www.vim.org/scripts/script.php?script_id=1000 – it contains syntax files for xlib, glib, gobject, gdk, gdk-pixbuf, gtk+, atk, pango, cairo, gimp, libgnome, libgnomecanvas, libgnomeui, libglade, gtkglext, vte, linc, gconf, and ORBit. And it’s in Portage (as app-vim/gtk-syntax).
Okay, well, I didn’t know this existed or was even possible with VIM! Thanks a bunch, both of you!