简体   繁体   English

如何获取vim,jsctags或ctags来将.js文件视为.html文件?

[英]How to get vim, jsctags, or ctags to treat a .js file as an .html file?

I'm trying to generate tags for a file that ends in .js. 我正在尝试为以.js结尾的文件生成标签。 This is what happens. 这就是发生的情况。

Didn't find a name for constructor^@^@node.js:201^@        throw e; // process.nextTick error, or 'error' event on first tick^@              ^^@Error: Didn't find a name for cons
tructor^@    at errorWithCode (/usr/local/lib/cfa2/jscfa.js:157:11)^@    at Array.toType (/usr/local/lib/cfa2/jscfa.js:1574:11)^@    at /usr/local/lib/cfa2/jscfa.js:1994:18^@
at Aval.forEachObj (/usr/local/lib/cfa2/jscfa.js:2020:5)^@    at Aval.toType (/usr/local/lib/cfa2/jscfa.js:1993:8)^@    at funToType (/usr/local/lib/cfa2/jscfa.js:3736:31)^@    a
t getTags (/usr/local/lib/cfa2/jscfa.js:3786:24)^@    at Object.interpret (/usr/local/lib/jsctags/ctags/interp.js:54:21)^@    at Object.scan (/usr/local/lib/jsctags/ctags/index.j
s:104:16)^@    at processPath (/usr/local/bin/jsctags:189:18)^@    

But if I just rename the file by changing .js to .html, then it works fine. 但是,如果我只是通过将.js更改为.html来重命名文件,则可以正常工作。

So something (either vim, ctags, or jsctags) is making some kind of decision based on file extension when generating tags. 因此,生成标签时,某些东西(vim,ctags或jsctags)会基于文件扩展名做出某种决定。

What's going on here? 这里发生了什么? Why does changing the filename extension to .html make it work? 为什么将文件扩展名更改为.html才能起作用?

I don't really know who generated this error message, but, as long as in the question title is stated that you need to make ctags to treat .js file as .html file, i suggest you to look at the ctags option --langmap . 我真的不知道是谁生成了此错误消息,但是,只要在问题标题中指出您需要制作ctags即可将.js文件视为.html文件,我建议您查看ctags选项--langmap

So, you need to pass the following option to ctags: --langmap=HTML:.js 因此,您需要将以下选项传递给ctags:-- --langmap=HTML:.js

But then, of course, all the .js files passed to ctags will be treated as HTML files. 但是,当然,所有传递给ctags的.js文件都将被视为HTML文件。

More detailed info about ctags options can be found here . 有关ctags选项的更多详细信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM