0

I'm working with typescript now, and I got this in my ~/.ctags file:

--langdef=typescript
--langmap=typescript:.ts
--regex-typescript=/^[ \t]*(export[ \t]+([a-z]+[ \t]+)?)?class[ \t]+([a-zA-Z0-9_$]+)/\3/c,classes/
--regex-typescript=/^[ \t]*(declare[ \t]+)?namespace[ \t]+([a-zA-Z0-9_$]+)/\2/c,modules/
--regex-typescript=/^[ \t]*(export[ \t]+)?module[ \t]+([a-zA-Z0-9_$]+)/\2/n,modules/
--regex-typescript=/^[ \t]*(export[ \t]+)?(default[ \t]+)?(async[ \t]+)?function(\*)?[ \t]+([a-zA-Z0-9_$]+)/\5/f,functions/
--regex-typescript=/^[ \t]*export[ \t]+(var|let|const)[ \t]+([a-zA-Z0-9_$]+)/\2/v,variables/
--regex-typescript=/^[ \t]*(var|let|const)[ \t]+([a-zA-Z0-9_$]+)[ \t]*=[ \t]*function[ \t]*[*]?[ \t]*\(\)/\2/v,varlambdas/
--regex-typescript=/^[ \t]*(export[ \t]+)?(public|protected|private)[ \t]+(static[ \t]+)?(abstract[ \t]+)?(((get|set)[ \t]+)|(async[ \t]+[*]*[ \t]*))?([a-zA-Z1-9_$]+)/\9/m,members/
--regex-typescript=/^[ \t]*(export[ \t]+)?interface[ \t]+([a-zA-Z0-9_$]+)/\2/i,interfaces/
--regex-typescript=/^[ \t]*(export[ \t]+)?type[ \t]+([a-zA-Z0-9_$]+)/\2/t,types/
--regex-typescript=/^[ \t]*(export[ \t]+)?enum[ \t]+([a-zA-Z0-9_$]+)/\2/e,enums/
--regex-typescript=/^[ \t]*import[ \t]+([a-zA-Z0-9_$]+)/\1/I,imports/

and jumping to definition etc works just fine, but when i show my tags bar, nothing is there!

for reference, here is my vimrc file, and my ctags file

enter image description here

update

i added this to my .vimrc:

let g:tagbar_type_typescript = {                                                  
  \ 'ctagsbin' : 'tstags',                                                        
  \ 'ctagsargs' : '-f-',                                                           
  \ 'kinds': [                                                                     
    \ 'e:enums:0:1',                                                               
    \ 'f:function:0:1',                                                            
    \ 't:typealias:0:1',                                                           
    \ 'M:Module:0:1',                                                              
    \ 'I:import:0:1',                                                              
    \ 'i:interface:0:1',                                                           
    \ 'C:class:0:1',                                                               
    \ 'm:method:0:1',                                                              
    \ 'p:property:0:1',                                                            
    \ 'v:variable:0:1',                                                            
    \ 'c:const:0:1',                                                              
  \ ],                                                                            
  \ 'sort' : 0                                                                    
\ }   

I also found out that when i run tagbar, I get this error message:

enter image description here

Tagbar: could not execute ctags for /path/to/file.ts!

note: my same tagbar setup works perfectly fine for my php files:

enter image description here

  • Did you read :help tagbar-extend? There is also a section on Typescript in the tagbar wiki. – Ralf Apr 5 at 6:09
  • I only use tagbar for a short time, I think tagbar create tags in real time, maybe something wrong with your tag build command. – dedowsdi Apr 5 at 6:49
  • updated question to address both comments @Ralf – abbood Apr 5 at 7:38
  • @dedowsdi where exactly is my tag build command? how do i debug it? – abbood Apr 5 at 7:39
  • Looking at your g:tagbar_type_typescript, I guess you now need an executable called tstags. – Ralf Apr 5 at 7:43
0

The bug was happening b/c I didn't have tstags executive installed.. so i got it from here and built it like so:

git clone https://github.com/Perlence/tstags.git

npm install -g
$home/.nvm/versions/node/v8.1.0/bin/tstags -> $home/.nvm/versions/node/v8.1.0/lib/node_modules/tstags/bin/tstags.js
+ tstags@0.1.0
added 14 packages in 3.518s

$ which tstags
$home/.nvm/versions/node/v8.1.0/bin/tstags

and it worked like a charm!

  • it is perfectly fine and I believe it is even recommended to mark your own answer as accepted, if you happen to find it before you get one from somebody else – AnonymousLurker Apr 6 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.