如何使 vim ctags 适用于现代 javascript

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4477322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 12:35:08  来源:igfitidea点击:

how to make vim ctags works for modern javascript

javascriptvimctags

提问by u443966

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

我正在使用 vim 和 ctags 来获取标签列表。但是对于 javascript,它不适用于这个约定

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

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

}

MyClass.prototype.method  = function () {
}

采纳答案by Ory Band

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

就像其他人所说的那样:DoctorJS(以前称为jsctags)是最好的选择。

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

但是,通过编写自定义包装器或使用 Vim-taglist-plus 插件将其与 Vim 集成,目前尚无法使用,并不是好的解决方案。

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

我发现的最简单的方法是安装TagBar Vim 插件注意:它是 TagBar,而不是旧的臭名昭著的 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.

有一个名为 tern.js 的新项目,它应该取代死掉的 Doctor.js。有关更多信息,请参阅上面的链接。

回答by tungd

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.htmland its website: http://doctorjs.org/.

正如@Benoit 回答的那样,您始终可以为 ctags 设置一种新语言;但是对于 JavaScript,您可能想尝试 DoctorJS(以前称为jsctags)。从作者看来,它是一个有限的 JS 环境,它记录了您的脚本制作的所有函数和对象,并将它们转换为与 vim 兼容的标签文件。这是原始帖子http://pcwalton.blogspot.com/2010/05/introducing-jsctags.html及其网站:http: //doctorjs.org/

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

要将它与 ctags 一起使用,我必须将 ctags 文件重命名为 smt likeex-ctags并编写一个名为 ctags 的包装脚本,它将根据--language.

回答by Benoit

You can setup new languages for ctags. See thisand that

您可以为 ctags 设置新语言。见这个那个

回答by Peter Host

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

如果你安装了doctorjs,你可以使用vim-taglist-plus插件,它是支持jsctags(doctorjs)的vim-taglist插件的一个分支:https: //github.com/int3/vim-taglist-plus