Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto import namespace like slamhound #286

Open
weejulius opened this issue Feb 22, 2014 · 9 comments
Open

Auto import namespace like slamhound #286

weejulius opened this issue Feb 22, 2014 · 9 comments
Milestone

Comments

@weejulius
Copy link

How about have the functionality like slamhound to auto import dependencies.

Thanks

@cursive-ide
Copy link
Owner

Yes, I'm planning to add this very soon, along with detecting unused imports and require declarations.

@cursive-ide cursive-ide added this to the Shortlist milestone Apr 24, 2014
@lucascs
Copy link

lucascs commented May 5, 2014

+1

@cursive-ide
Copy link
Owner

Note that this functionality is partially available now, since 0.1.21. If you type the name of a symbol qualified with an alias which is used elsewhere in your project but isn’t require’d yet in your current namespace, Cursive will automatically add the require when you complete the symbol. For example, if you type (str/tr|) (where | represents the caret) and you autocomplete, you’ll see a completion item like trim (clojure.string :as str). If you select this completion, clojure.string :as str will be added to your requires automatically. This will also work in the REPL editor, but the require will be executed in the current namespace instead of added to the require list.

@lucascs
Copy link

lucascs commented May 6, 2014

I know about it and I like it very much =) (although it appears only work if I already required the namespace somewhere with that alias)

But highlight the unused requires and imports as unused would be very helpful to me.

And maybe sorting the requires/imports alphabetically.

@cursive-ide
Copy link
Owner

Yes, currently it will use your previous requires as an example, I'm planning to improve this soon, and unused requires/imports is coming very soon too. There's also an outstanding issue (#77) for organising ns forms - I'll be doing that at some stage, but I'm going to wait until the unused requires/imports functionality is stable first. My end goal is to never have to look at the ns form at all, much like imports in Java.

@lucascs
Copy link

lucascs commented May 6, 2014

The current way is fine, since I try to write the tests referring to the namespace with a suggested alias for it =) Problem is only when I forget which was this alias :P

anyway, obvious choices would be initials and the last word from namespace:

my-system.some.thing => suggested when using mst and thing as alias.

@lucascs
Copy link

lucascs commented May 6, 2014

I also miss that "always automagic imports" that all Java IDEs have =)

Anyway, nice work!

@cursive-ide
Copy link
Owner

Yeah, I'm actually just going to use the matching that's currently used during symbol completion, which would catch both of those cases. I'm not sure if it's going to be too permissive and return too many results though, time will tell.

@lucascs
Copy link

lucascs commented May 6, 2014

Maybe adding it only on the SmartType completion (ctrl + shift + space)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants