Skip to content

Instantly share code, notes, and snippets.

@mfwarren
Created January 24, 2011 16:34
Show Gist options
  • Save mfwarren/793482 to your computer and use it in GitHub Desktop.
Save mfwarren/793482 to your computer and use it in GitHub Desktop.
my .ctags syntax file for Groovy language (exuberant-ctags)
--langdef=groovy
--langmap=groovy:.groovy
--regex-groovy=/^[ \t]*[(private|public|protected) ( \t)]*def[ \t]+([A-Za-z0-9_]+)[ \t]*\(/\1/f,function,functions/
--regex-groovy=/^[ \t]*private def[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/v,private,private variables/
--regex-groovy=/^[ \t]*public def[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/u,public,public variables/
--regex-groovy=/^[ \t]*[abstract ( \t)]*[(private|public) ( \t)]*class[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/c,class,classes/
--regex-groovy=/^[ \t]*[abstract ( \t)]*[(private|public) ( \t)]*enum[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/c,class,classes/
@dreki
Copy link

dreki commented Dec 2, 2013

This alteration supports methods of the form def whatever = {:

--langdef=groovy
--langmap=groovy:.groovy
--regex-groovy=/^[ \t]*[(private|public|protected) ( \t)]*def[ \t]+([A-Za-z0-9_]+)[ \t()=]*\{/\1/f,function,functions/
--regex-groovy=/^[ \t]*private def[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/v,private,private variables/
--regex-groovy=/^[ \t]*public def[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/u,public,public variables/
--regex-groovy=/^[ \t]*[abstract ( \t)]*[(private|public) ( \t)]*class[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/c,class,classes/
--regex-groovy=/^[ \t]*[abstract ( \t)]*[(private|public) ( \t)]*enum[ \t]+([A-Za-z0-9_]+)[ \t]*/\1/c,class,classes/

@rwilcox
Copy link

rwilcox commented May 11, 2015

I've found that the function line needs the following tweaking:

--regex-groovy=/^[ \t]*[(static|private|public|protected) \t]*(def|[A-Za-z0-9_.]+)[ \t]+([A-Za-z0-9_]+)[ \t]*\(/\2/f,function,functions/

Beyond that, the rest of the .ctags file worked for me

@ches
Copy link

ches commented Apr 11, 2016

I've worked up some rules that match a lot more syntax—they're on my fork of this gist, on the Tagbar wiki, and submitted as a pull request to a vim-gradle plugin that includes ctags and Tagbar config built-in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment