vim-lambdify icon indicating copy to clipboard operation
vim-lambdify copied to clipboard

Javascript named Functions shouldn't be lambdafied

Open geofflane opened this issue 9 years ago • 3 comments

These are currently correct: var foo = function() { } - is lambdified as var foo = λ _.map(arg, function(x) {}) is lambdified as _.map(arg, λ (x) {})

But a named function like: function foo(args) {} currently turns into λ foo(args) {}. That didn't seem correct to me. It should be left alone since it's a named function and not an anonymous.

geofflane avatar Jul 22 '15 17:07 geofflane

Thanks for the issue. This is a good point, which I hadn't really thought about.

I think a function expression is appropriate with lambdas, but as you said, not a function definition. I'm not sure if JavaScript syntax files make this distinction though, which makes this kind of difficult. I might be able to look into this eventually, but if not, I'm open to a PR for this issue if someone is aware of a good way to handle this (a commonly used/installed syntax file that does distinguish between them, because at a glance it doesn't seem to).

calebsmith avatar Jul 22 '15 22:07 calebsmith

@calebsmith I looked at the lambdify_match function and was kind of wondering if it could be switched to that instead? But my vimscript foo is pretty weak.

geofflane avatar Jul 22 '15 23:07 geofflane

@geofflane Apologies for letting this slip for a while. I kept meaning to get to this.

Yes, as a general idea, switching between those two functions should allow for syntax-based vs. regex based approaches if I recall correctly.

Since I've been terrible at getting around to this, would it be helpful to you if I document the workflow for working with this plugin? I don't know how other plugin authors do it but I've worked a fairly simple way to test out changes like this and I'm happy to help you get ramped up if you're interested. (if not, no worries)

calebsmith avatar Jan 04 '16 14:01 calebsmith