Closed igorcafe closed 2 years ago
This would need to be brought up with the universal-ctags team first. I tested the code you have and currently ctags doesn't recognize the async <name> ()
format as a function. Here is the raw ctags output that tagbar has to work with. Once universal ctags can support this function syntax, we can verify that tagbar can detect and display it correctly.
tagbar (master) tagbar-test-files$ ctags --extras=+F -f - --format=2 --excmd=pattern --fields=nksSafet --sort=no --append=no -V --language-force=javascript --javascript-kinds=vcCgpmf test.js
Option: --language-force=javascript
Option: --javascript-kinds=vcCgpmf
Initialize parser: JavaScript
Reading command line arguments
OPENING test.js as JavaScript language file [new]
response test.js /^ const response = await axios.get('api\/school-system\/users\/me')$/;" C line:5
formData test.js /^ const formData = new FormData()$/;" C line:10
response test.js /^ const response = await axiot.put('api\/school-system\/users\/me', payload)$/;" C line:20
response test.js /^ const response = await axios.put('api\/auth\/change-password', user)$/;" C line:25
response test.js /^ const response = await axios.post('api\/auth\/password-recovery\/change-password', user)$/;" C line:31
tagbar (master) tagbar-test-files$
@igoracmelo I've pushed up a change that might give partial support for this. Take a look at #811 and see if this will work for your case. I tested it out using the example you gave and the following definitions in my .vimrc and it seemed to work for me.
let g:tagbar_type_javascript = {
\ 'ctagstype' : 'javascript',
\ 'regex' : [
\ '/async[ \t]+(.*)[ \t]*\(.*\)/\1/f/func/function/',
\ ],
\ 'kinds' : [
\ 'v:global variables:0:0',
\ 'C:constants:0:0',
\ 'c:classes:0:1',
\ 'g:generators:0:0',
\ 'p:properties:0:0',
\ 'm:methods:0:1',
\ 'f:functions:0:0',
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 'c' : 'class',
\ 'f' : 'function',
\ 'm' : 'method',
\ 'p' : 'property',
\ },
\ 'scope2kind' : {
\ 'class' : 'c',
\ 'function' : 'f',
\ },
\ }
Sorry if it is not tagbar's "fault", but when using this type of syntax with javascript the tags aren't quite right...![image](https://user-images.githubusercontent.com/85039990/144715792-84d66bf3-30e0-403b-8f63-197df8edaf15.png)
This works:![image](https://user-images.githubusercontent.com/85039990/144715886-79223b04-ccdc-4c43-815e-e56bdd5a5f4e.png)