cursive-ide / cursive

Cursive: The IDE for beautiful Clojure code
590 stars 7 forks source link

Auto suggest :require alias when typing in :require block #853

Open danielcompton opened 9 years ago

danielcompton commented 9 years ago

In most of my projects if I'm requiring a namespace in multiple files I'll use the same alias for that namespace. Cursive can already figure out if I try to refer to a var with alias/my-function and I've used that alias elsewhere that it should suggest importing that namespace into this file.

Is it possible for it also to make suggestions when I am typing the namespace in the :require form? So when I start typing a previously aliased namespace:

  1. In the namespace autocompletion, it adds :as alias as an autocomplete option
  2. Once you've typed a namespace and :as, it opens an autocomplete menu with likely suggestions based on previous namespace aliasing.

I'm not sure which of these would be better, or maybe both could work together?

cursive-ide commented 9 years ago

Yeah, this is a great idea - I guess you'd probably want both. One issue with 1 would be that you might want to use a different alias from time to time, I'm not sure if the namespace should be presented twice in the completion list (with and without the alias). Once you've typed the :as, you'd definitely want autocomplete to suggest your previous usages.

danielcompton commented 9 years ago

I'd lean toward having the aliased ns as the first suggestion as I assume that would be the common case, and have the non-aliased version second in the list.

I imagine it's probably something you'd need to live with a little to see what feels most natural. Happy to beta test if that's helpful, I'm doing a massive amount of ns cleanup so it's been on my mind a bit.

danielcompton commented 9 years ago

Hmm, having two of every ns might get a bit annoying, this probably deserves some hammock time.