Justin Palmer's Vibrant Ink bundle [1] includes a small syntax addon for this sort of construct. With his blessing, I've made tentative plans to move some of this into the main JavaScript bundle. Someday. Meanwhile, you can use his.
Hi,
I would like to suggest the following enhancement to the Javascript syntax:
{ name = 'meta.function.js';
comment = 'match stuff like: foobar: function() { … }';
match = '^\s*\b([a-zA-Z_?\.$]+\w*):\s+\b(function)?\s*\((.*?)\)';
captures =
{ 1 = { name = 'entity.name.function.js'; };
2 = { name = 'storage.type.function.js'; };
3 = { name = 'variable.parameter.function.js'; };
};
},
Since the common style in a lot of Javascript libraries (like Prototype/scriptaculous) is to define functions like this:
var Enumerable = {
each: function(iterator) {
// body
},
all: function(iterator) {
// body
}
}
The above rule correctly highlights these definitions and also includes their names in the function popup.
Regards,
Aparajita