alexander-yakushev / compliment

Clojure completion library that you deserve
Eclipse Public License 1.0
355 stars 38 forks source link

Recognise alternative let-like formats #76

Open vemv opened 3 years ago

vemv commented 3 years ago

Brief

The following vars:

https://github.com/alexander-yakushev/compliment/blob/a112bb85b748d4a34da89ee783e7c64d8183dab7/src/compliment/sources/local_bindings.clj#L6-L13

represent closed sets and typically only will work over clojure.core symbols. So if one uses e.g. my/let, completion accuracy will degrade.

Proposal

In:

https://github.com/alexander-yakushev/compliment/blob/a112bb85b748d4a34da89ee783e7c64d8183dab7/src/compliment/sources/local_bindings.clj#L55

Instead of doing (first form) (which will return let, my/let, etc), perform (-> form first name symbol). This way let-like-forms will work as usual, but also admitting alternative mechanisms that share the name but use a different namespace.

Same for defn, doseq, letfn.

Alternatives

Consumers could use alter-var-root! over the mentioned vars, although that doesn't seem a clean thing to do (and would also have to account for different ns aliases: my/let, com.domain.my/let, etc - which is not a closed set)

Thanks - V

alexander-yakushev commented 3 years ago

Hi, could you please check #77 first? Would it perhaps be enough if I merged something like that?

vemv commented 2 years ago

https://github.com/alexander-yakushev/compliment/pull/77

alexander-yakushev commented 2 years ago

Actually, I agree with your point that it makes sense having it "for free" for symbols that have names exactly like let and defn. I mean, what's the worst that can happen? We guard ourselves against errors already, so at worst we might suggest some redundant locals within such macros, whatever.

I'll keep this open for now.

vemv commented 2 years ago

Ok nice!

I have a patch around, should be at hand