how to make vim ctags works for modern javascript

烂漫一生 提交于 2019-12-04 07:50:16

问题


I am using vim and ctags to get taglist. but for javascript, it does not works for this convention

MyClass.extend({
  xxx: function(){
  },
   ...
})

MyClass.prototype = {
    method : function(){ }

}

MyClass.prototype.method  = function () {
}

回答1:


Like the others had said: DoctorJS (formerly jsctags) is the best option.

However, integrating it with Vim by writing custom wrappers or using Vim-taglist-plus plugin, which isn't currently working, aren't good solutions.

The easiest way I've found is to install the TagBar Vim plugin (NOTE: It's TagBar, not the old infamous TagList!).

See my other answer for more info.

Edit:

There's a new project called tern.js which should replace the dead doctor.js. See the link above for more info.




回答2:


As @Benoit answered, you can always setup a new languages for ctags; however in the case of JavaScript, you may want to try DoctorJS (formerly jsctags). From the author it is a limited JS environment that records all the functions and objects your script made and turns them into vim-compatible tags file. Here is the original post http://pcwalton.blogspot.com/2010/05/introducing-jsctags.html and its website: http://doctorjs.org/.

To use it with ctags I have to rename the ctags file to smt like ex-ctags and write a wrapper script named ctags which will switch the tool depending on --language.




回答3:


You can setup new languages for ctags. See this and that




回答4:


provided you install doctorjs, you can use the vim-taglist-plus plugin, which is a fork of the vim-taglist plugin with jsctags (doctorjs) support : https://github.com/int3/vim-taglist-plus



来源:https://stackoverflow.com/questions/4477322/how-to-make-vim-ctags-works-for-modern-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!