sergioramos / jsctags

jsctags generator using tern
476 stars 47 forks source link

no tag found using with tagbar #49

Open GeekaholicLin opened 7 years ago

GeekaholicLin commented 7 years ago

I want to use jsctags and tagbar in vim,but there were something wrong.

When I used them in vim,the tagbar always said 'no tag found'.

I used the command find . -type f -iregex ".*\.js$" -exec jsctags {} -f \; | sed '/^$/d' | sort > tags for a test file test.js, and it created a file named 'tags' in the directory.The file tags showes the result of the command successfully.

The content of file:

a   D:\babun\.babun\cygwin\home\Garcin\test\test.js /a/;"   f   lineno:1    type:void function()
b   D:\babun\.babun\cygwin\home\Garcin\test\test.js /b/;"   v   lineno:19   namespace:y type:boolean
b   D:\babun\.babun\cygwin\home\Garcin\test\test.js /b/;"   v   lineno:29   type:number
e1  D:\babun\.babun\cygwin\home\Garcin\test\test.js /e1/;"  v   lineno:33   type:string
e3  D:\babun\.babun\cygwin\home\Garcin\test\test.js /e3/;"  v   lineno:33   type:number
Foo D:\babun\.babun\cygwin\home\Garcin\test\test.js /Foo/;" f   lineno:4    type:void function(?, ?)
func    D:\babun\.babun\cygwin\home\Garcin\test\test.js /func/;"    f   lineno:18   namespace:y type:number function()
it  D:\babun\.babun\cygwin\home\Garcin\test\test.js /it/;"  f   lineno:23   type:!0 function(?)
method  D:\babun\.babun\cygwin\home\Garcin\test\test.js /method/;"  f   lineno:10   namespace:Foo.prototype type:void function()
n   D:\babun\.babun\cygwin\home\Garcin\test\test.js /n/;"   v   lineno:23   namespace:it
prototype   D:\babun\.babun\cygwin\home\Garcin\test\test.js /class Foo \{/;"    v   lineno:4    namespace:Foo
x   D:\babun\.babun\cygwin\home\Garcin\test\test.js /x/;"   v   lineno:12   namespace:Foo.prototype type:string

But when I toggle the tagbar, it does not work.And I found a issue in the repo majutsushi/tagbar.

Are there any configs that I should write in my vimrc file to let it work correctly for js?

jchain commented 7 years ago

I have the same issue. I compared the formats jsctags and ctags(vanilla) and found out the two are a bit different. Especially the 'lineno' part. I guess tagbar can't parse the jsctags correctly so shows nothing in the side windows.

majutsushi commented 7 years ago

Tagbar doesn't use pre-generated tags files, it generates the necessary information on the fly. That said, this should work automatically as long as jsctags is in your $PATH. If it is and it is still not working, please generate a logfile as explained in :h tagbar-issues and open a new issue in the Tagbar repo.

The lineno part should work, Tagbar has a special case for that.