Skip to content

Instantly share code, notes, and snippets.

@bjornharrtell
Forked from yury/Coffeescript ctags
Created June 9, 2012 17:14
Show Gist options
  • Save bjornharrtell/2901844 to your computer and use it in GitHub Desktop.
Save bjornharrtell/2901844 to your computer and use it in GitHub Desktop.
ctags definitions for coffeescript. Detects classes, static/class methods, fields, static fields, plain functions, 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/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/
@ku1ik
Copy link

ku1ik commented Jul 13, 2012

With following valid CoffeeScript code:

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

I get:

ctags: Warning: a.coffee:2: null expansion of name pattern "\3"

@Tyderion
Copy link

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 :)

@Gonzih
Copy link

Gonzih commented Feb 22, 2013

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

@jesstelford
Copy link

@Gonzih / @Tyderion / @bjornharrtell - I have updated this gist to cover more cases, and documented those cases in my fork: https://gist.github.com/jesstelford/6134172

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