Skip to content

Instantly share code, notes, and snippets.

@AndrewRadev
Forked from wereHamster/Coffeescript ctags
Created February 28, 2012 13:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AndrewRadev/1932675 to your computer and use it in GitHub Desktop.
Save AndrewRadev/1932675 to your computer and use it in GitHub Desktop.
ctags definitions for coffeescript
# Detects classes, static/class methods, plain functions and variables.
# To use, place it in a ~/.ctags file.
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z.]+)( extends [A-Za-z.]+)?$/\2/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/
@rosenfeld
Copy link

You can also declare a class like this:

(export ? window).MyClass = class MyClass
constructor: ...

I mean, it doesn't need to start with "class":

https://gist.github.com/2405554

@AndrewRadev
Copy link
Author

You're right :). I don't use classes much, so I guess I never took a good look at this particular regex. Thanks.

@rosenfeld
Copy link

No problem, we're all trying to get ctags properly set up for CoffeeScript ;)

@yury
Copy link

yury commented May 6, 2012

Maybe it is better to take last part from class definition? https://gist.github.com/2624883

class GS.Views.Campaign extends Backbone.View
   ....

I want just Campaign in my autocompletion list instead of GS.Views.Campaign. In fact, I can't autocomplete classes with dots in sublime %(

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