Skip to content

Instantly share code, notes, and snippets.



Forked from jesstelford/.ctags
Last active Jan 3, 2020
What would you like to do?
--regex-moonscript=/(^|=[ \t])*class ([A-Za-z_][A-Za-z0-9_]+\.)*([A-Za-z_][A-Za-z0-9_]+)( extends ([A-Za-z][A-Za-z0-9_.]*)+)?$/\3/c,class/
--regex-moonscript=/^[ \t]*@?(([A-Za-z][A-Za-z0-9_.]*)+):.*[-=]>.*$/\1/m,method/
--regex-moonscript=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=.*[-=]>.*$/\1/f,function/
--regex-moonscript=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/v,variable/
--regex-moonscript=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/p,property/
--regex-moonscript=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/s,static property/
--regex-moonscript=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?/\3/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){0}/\8/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){1}/\8/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){2}/\8/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){3}/\8/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){4}/\8/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){5}/\8/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){6}/\8/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){7}/\8/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){8}/\8/p,property/
--regex-moonscript=/(new:[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){9}/\8/p,property/
let g:tagbar_type_moon = {
\ 'ctagstype' : 'moonscript',
\ 'kinds' : [
\ 'v:variables',
\ 'f:functions',
\ 'c:classes',
\ 'm:methods',
\ 's:static properties',
\ 'p:properties',
\ ]
\ }

Moonscript ctags regexes


Save .ctags to ~/.ctags or append it to the end of your existing ~/.ctags.

If you use Tagbar for Vim add the contents of .vimrc to ~/.vimrc

Example Coverage

These regexes should cover all of the following:


class MyAwesomeClass                         # tag = MyAwesomeClass
class my_Class                               # tag = my_Class
class Namespace.MyClass                      # tag = MyClass
class Namespace.Child extends Namespace.Base # tag = Child

Methods / Functions

doIt: ->                # tag = doIt
zip = ->                # tag = zip
fooBar: (param) ->      # tag = fooBar
bazZoo: => x * x        # tag = bazZoo

Variables / Fields

my_Var = 'foo'     # tag = myVar
@local_Var = 'bar' # tag = localVar
prop: 'bar'        # tag = prop
@bam: 'zoo'        # tag = bam

Variables / Fields declared within the parameter list of new()

new: (@foo) ->                # tag = foo
new: (@bar, @zip) ->          # tags = bar, zip
new: (@prop = {}) ->           # tag = prop
new: (@baz={}, @me = 'foo') -> # tags = baz, me


@bjornharrtell for the original Coffeescript gist
@jesstellford and @Tyderion for additions to the original

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.