Skip to content

Instantly share code, notes, and snippets.

@yury
Forked from AndrewRadev/Coffeescript ctags
Created May 6, 2012 22:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yury/2624883 to your computer and use it in GitHub Desktop.
Save yury/2624883 to your computer and use it in GitHub Desktop.
ctags definitions for coffeescript. Detects classes, static/class methods, plain functions and variables.
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z]+\.)*([A-Za-z]+)( extends [A-Za-z.]+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?([A-Za-z.]+):.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?([A-Za-z.]+)[ \t]+=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/
@edubkendo
Copy link

This gets much closer than the last one I tried, doesn't seem to get @variables though. If I knew enough about regex and/or my brain wasn't frazzled from being determined to make this work for the last six hours, I'd attempt to make the adjustment myself. Might look at it later.

@bjornharrtell
Copy link

Very usable already but would love to get the @vars of course... regexp also hurts my brain though :(

One caveat when using with gedit and gedit-source-code-browser is that you can't have the # comments in the .ctags file..

@edubkendo
Copy link

@bjornharrtell et all, adding this line at the end will catch some, but unfortunately not all, of the @variables:

--regex-coffee=/^[ \t]*(@[A-Za-z]+)[ \t]*=.*$/\1/i,ivar/

@bjornharrtell
Copy link

Hmm doesn't work for me. What does work for me in initial tests is several patterns and repeating one for multiple definitions passed in constructor... check out https://gist.github.com/2901844

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