Vim Tagbar is empty after installing CoffeeTags

2

I'm having the hardest time getting CoffeeTags to run in Vim.

As the website suggests, I've installed the CoffeeTags gem and appended the configuration to my ~/.vimrc. When I open Tagbar it's empty.

Here's a screenshot summarizing the problem:

Am I missing something? I'm running Ruby 1.9.2, Vim 7.3, CoffeeScript 1.1.3, and Node.js 0.6.2. and OS X Lion.

Roshambo

Posted 2011-12-02T20:48:38.247

Reputation: 129

Answers

0

It turns out that it was Ruby. As far as I can tell, CoffeeTags doesn't work in Ruby 1.9. After switching to Ruby 1.8 CoffeeTags worked flawlessly.

I verified this on OS X 10.7.2 running rvm and Arch Linux not running rvm.

Roshambo

Posted 2011-12-02T20:48:38.247

Reputation: 129

For what it's worth, CoffeeTags does work with Ruby 1.9. I just verified this myself, though that still doesn't get to the root of your problem. – Marcus – 2012-04-10T18:15:29.383

5

CoffeeTags seems to generate invalid tags files for me. Whenever I tried to use tags files generated by it in vim I would get:

Error detected while processing function <SNR>19_CommandTShowTagFinder:
line    2:
E431: Format error in tags file "tags"
Before byte 156
Press ENTER or type command to continue

In the end I'm not sure how necessary it is. I added this:

--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/

to my ~/.ctags file and then just used the regular exuberant-ctags utility: find . -iname '*\.coffee*' | ctags -L-

ralfthewise

Posted 2011-12-02T20:48:38.247

Reputation: 151

0

The most likely explanation is that your filetype is set incorrectly. Try :set filetype? in one of your coffeescript buffers. The configuration that the gem creates assumes that the filetype is set to coffee, so if that's not the case for you then it won't work. In that case add a line like this to your vimrc:

autocmd BufNewFile,BufReadPost *.coffee setfiletype coffee

Maybe I should add a note about that in an empty Tagbar window...

Jan Larres

Posted 2011-12-02T20:48:38.247

Reputation: 103

Please do add that note: We love extra information! – Simon Sheehan – 2011-12-02T23:47:00.703

Odd, still no luck. :set filetype definitely returns filetype=coffee yet the Tagbar window remains empty. I'm so stumped with this. – Roshambo – 2011-12-04T00:30:11.160

Hm, then I can't think of anything specific offhand. Have you tried calling coffeetags manually to see whether it actually generates tags for your file? Is it in your $PATH? Is your vimrc available somewhere? – Jan Larres – 2011-12-05T08:00:09.807

CoffeeTags at the commandline seems to be generating tags properly and it's in my path. Here's my .vimrc and .gvimrc.

– Roshambo – 2011-12-05T20:09:21.833

0

If you don't want to install ruby tagbar docs suggest: https://github.com/majutsushi/tagbar/wiki

let g:tagbar_type_coffee = {
    \ 'ctagstype' : 'coffee',
    \ 'kinds'     : [
        \ 'c:classes',
        \ 'm:methods',
        \ 'f:functions',
        \ 'v:variables',
        \ 'f:fields',
    \ ]
\ }

" Posix regular expressions for matching interesting items. Since this will 
" be passed as an environment variable, no whitespace can exist in the options
" so [:space:] is used instead of normal whitespaces.
" Adapted from: https://gist.github.com/2901844
let s:ctags_opts = '
  \ --langdef=coffee
  \ --langmap=coffee:.coffee
  \ --regex-coffee=/(^|=[ \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-coffee=/^[ \t]*(module\.)?(exports\.)?@?(([A-Za-z][A-Za-z0-9_.]*)+):.*[-=]>.*$/\3/m,method/
  \ --regex-coffee=/^[ \t]*(module\.)?(exports\.)?(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=.*[-=]>.*$/\3/f,function/
  \ --regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/v,variable/
  \ --regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/f,field/
  \ --regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,static field/
  \ --regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?/\3/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){0}/\8/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){1}/\8/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){2}/\8/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){3}/\8/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){4}/\8/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){5}/\8/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){6}/\8/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){7}/\8/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){8}/\8/f,field/
  \ --regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?(,[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?){9}/\8/f,field/'

let $CTAGS = substitute(s:ctags_opts, '\v\\([nst]\)', '\\\\\1', 'g')

zzart

Posted 2011-12-02T20:48:38.247

Reputation: 321