문제

I'm using a taglist plugin for a few days and now I tried it with Javascript, but in Javascript it shows only partial information or no information. It seems that the problem could be with namespaces, because the functions are in

var namespace_name = {

f1: function() {
},
f2: function() {
},
.
.
.

};

or this sort of functions (anonymous)

var something = (function f() {
   }
   ...
})();

Do you know how to correct this problem?

thank you

도움이 되었습니까?

해결책

Did you try TagBar? It's a more modern take on the same idea which works better with JavaScript and even supports jsctags.

taglist on the left, tagbar on the right

TagList on the left, TagBar on the right.

TagList doesn't work because Exuberant ctags (the program used by TagList to index your code) is not very good with JavaScript, especially the modern stuff with callbacks, closures and self executing functions.

On the other hand, TagBar uses jsctags for JavaScript if it's available. Jsctags is made with modern JavaScript in mind and as such works a lot better.

Compare these tag files generated against the following code (based on your samples):

var namespace_name = {

    f1: function() {
        window.alert("f1");
    },
    f2: function() {
        window.alert("f2");
    }
};
var something = (function f() {
    window.alert("something");
})();

Output of $ ctags .:

// empty file expect for the header

Output of $ jsctags .:

// skipped header
namespace_name  test.js /^var namespace_name = {$/;"    v   lineno:1    type:Object
f1  test.js /^\tf1: function() {$/;"    f   lineno:3    type:void function()
f2  test.js /^\tf2: function() {$/;"    f   lineno:6    type:void function()
f   test.js /^var something = (function f() {$/;"   f   lineno:11   type:void function()
something   test.js /^var something = (function f() {$/;"   v   lineno:11   type:undefined

There are a bunch of questions on SO about customizing exuberant ctags to make it work better with JavaScript: here and here.

So, basically, there are two ways to solve your problem: customize ctags or use tagbar+jsctags.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top