Skip to content

@bjornharrtell /Coffeescript ctags forked from yury/Coffeescript ctags

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
ctags definitions for coffeescript. Detects classes, static/class methods, fields, static fields, plain functions, variables.
--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/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?([A-Za-z.]+)[ \t]+=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@([A-Za-z.]+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*([A-Za-z.]+):[^->\n]*$/\1/f,field/
--regex-coffee=/(constructor: \()@([A-Za-z.]+)/\2/f,field/
--regex-coffee=/(constructor: \()@[A-Za-z.]+(, @([A-Za-z.]+)){0}/\3/f,field/
--regex-coffee=/(constructor: \()@[A-Za-z.]+(, @([A-Za-z.]+)){1}/\3/f,field/
--regex-coffee=/(constructor: \()@[A-Za-z.]+(, @([A-Za-z.]+)){2}/\3/f,field/
--regex-coffee=/(constructor: \()@[A-Za-z.]+(, @([A-Za-z.]+)){3}/\3/f,field/
--regex-coffee=/(constructor: \()@[A-Za-z.]+(, @([A-Za-z.]+)){4}/\3/f,field/
--regex-coffee=/(constructor: \()@[A-Za-z.]+(, @([A-Za-z.]+)){5}/\3/f,field/
--regex-coffee=/(constructor: \()@[A-Za-z.]+(, @([A-Za-z.]+)){6}/\3/f,field/
--regex-coffee=/(constructor: \()@[A-Za-z.]+(, @([A-Za-z.]+)){7}/\3/f,field/
--regex-coffee=/(constructor: \()@[A-Za-z.]+(, @([A-Za-z.]+)){8}/\3/f,field/
--regex-coffee=/(constructor: \()@[A-Za-z.]+(, @([A-Za-z.]+)){9}/\3/f,field/

Adding to previous ctags definition in order of addition:

static field defined in class by @field = something
static field defined in class by @field: something
field defined in class by field: something
first field defined in class constructor by @first
second field defined in class constructor by @first, @second
third field defined in class constructor by @field, @second, @third

The constructor defined field regexp is of course not optimal... From what I can tell though there is no way to get multiple matches per line so I guess you'll have to do something like this would like to remove the repeating stuff so a more reasonable amount of max constructor fields can be matched.


Updated with better regexp to get fields defined in constructor thanks to osse at #regex which least avoids repeating inside patterns and will match up to 11 fields defined in constructor. It would of course be nicer to get all matches with one pattern but I don't see how that's possible, at least with which seem to be the defacto implementation of ctags. (I think it does not support the g flag for regex, which might be what is needed here)


Yup. Actually saw this shortly after I posted that line in the other gist, and thought I had commented but it wasn't until I saw your comment that I realized I had never sent it. This is much more consistent than the other one, so kudos . Will be using this for now. Thanks.


Changed so that @field = something translates to field not static field, since that syntax is most often used inside methods to assign fields. It can be used at class level to create static fields, but I think @field: something is the syntax to use instead.


With following valid CoffeeScript code:

class Jola
  constructor: (@misio) ->
    console.log @misio

I get:

ctags: Warning: null expansion of name pattern "\3"

This regex does not parse functions containing underscores.
The rest works for me though....
I'm not good enough with regex to change yours to accept underscores in function names.
It would be highly appreciated if you'd add this :)


@Tyderion I think I fixed that, take a look at my fork.


@Gonzih / @Tyderion / @bjornharrtell - I have updated this gist to cover more cases, and documented those cases in my fork:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.