Question

I'm trying to use tagbar for reading code in jquery-1.7.1.js(renamed jquery.js) ,but it

doesn't work and display any errors :

"your ctags and tagbar configuration are out of sync! ".

And my ~/.ctags file:

    --regex-JavaScript=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*new[ \t]+Object\(/\1/o,object/
    --regex-JavaScript=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/o,object/
    --regex-JavaScript=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/f,function/
    --regex-JavaScript=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*\([^\]\)]*\)/\1/f,function/
    --regex-JavaScript=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*new[ \t]+Array\(/\1/a,array/
    --regex-JavaScript=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/a,array/
    --regex-JavaScript=/([^= ]+)[ \t]*=[ \t]*[^""]'[^'']*/\1/s,string/
    --regex-JavaScript=/([^= ]+)[ \t]*=[ \t]*[^'']"[^""]*/\1/s,string/
Was it helpful?

Solution

You should have read the second line of that error message, which says: "Please read ':help tagbar-extend'".

When you are defining a new language with ctags (or change an existing one) you also need to supply a corresponding Tagbar configuration so Tagbar knows that there is a new language and how to interpret ctags' output. In your case a configuration like this should work (put it into your ~/.vimrc):

let g:tagbar_type_javascript = {
    \ 'ctagstype' : 'JavaScript',
    \ 'kinds'     : [
        \ 'o:objects',
        \ 'f:functions',
        \ 'a:arrays',
        \ 's:strings'
    \ ]
\ }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top