calebsmith / vim-lambdify

Vim plugin that conceals lambda/function syntax with lambda characters
BSD 2-Clause "Simplified" License
52 stars 8 forks source link

Javascript named Functions shouldn't be lambdafied #7

Open geofflane opened 9 years ago

geofflane commented 9 years ago

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.

calebsmith commented 9 years ago

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).

geofflane commented 9 years ago

@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.

calebsmith commented 8 years ago

@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)