-
Notifications
You must be signed in to change notification settings - Fork 7
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
Detect/suggest correct Clojure filetype #904
Comments
I like the defaulting rules - they make sense. It might take me a while to get to them, though! I'm not so keen on part II, since the idea is that the user enters the namespace's name, not the filename. This is why you get the namespace called And yes, up/down work nicely here :-) |
IMHO part II is a bug since it is not how IntelliJ behaves. In a Web project, "New/Html File" and enter in the name filed |
That's because it's creating a file, not a namespace. If you create a new Java class, you don't enter ClassName.java, just ClassName. |
@cursiveclojure
It doesn't matter, IntelliJ behaves intelligently here too: if I type however |
Right, but that is unambiguous. If I add logic like that, it will be impossible to create a namespace ending in a |
IMHO since Cursive is an IntelliJ plug-in, it should behave like the rest of IntelliJ. In Java and other plug-ins is also not possible this way. It would be better to separate stuff, with Menus items like:
|
In Java it's very uncommon to create a class called The problem with what you're suggesting is that there isn't a distinction between a namespace and a file (a namespace filesystem sequence ends in a file, unlike a package which is represented by a directory). There is also no distinction between a Clojure script file and a standard Clojure file. The only difference I can imagine needing there is the ability to create a Clojure file with no namespace at all. Either way, I'm not going to add confusing options just to maintain a very minor consistency point with IntelliJ. The current functionality allows everything to be done in an intuitive way - this issue is just to provide some more sensible defaulting (which I think is a good idea). |
Sounds good to me 👍 |
If this is complicated to implement properly an 80% solution to my mind would be to just remember the last type used. Yes it will be wrong sometimes but in my experience I am mostly writing one type so the number of mistakes likely wouldn't increase but 80% of the time it would be right after the first time. Just a thought. |
I agree with @mmower, probably 80%+ of my ClojureScript files start life as Clojure files until I realise I've created the wrong type. |
Is there any progress on this issue? I've just hit yet another bug that was simply that I ended up creating a CLJ file in my CLJS project. It really drives you mad and is, for me, the main chafing point using Cursive. I realise there's lots of other stuff you want to do but this doesn't seem such a difficult issue to come up with an 80% solution and it's been almost a year and a half that people have been dealing with it. |
This is fixed for the next build. Here's how this works:
IntelliJ actually automatically removes the file extension corresponding to the file template. What this means is that if you create a Clojure namespace with a name ending in |
Part the first
In a hybrid clj/cljs project, when I create a new namespace in the ClojureScript section of the source paths, Cursive suggests making a .clj file, not .cljs. I can imagine improving this by adding a few heuristics to guess the filetype like:
It's quite possible I'm doing something wrong and this is meant to be automatic, I checked the docs and couldn't see anything about it though. There's also lots of ambiguity and dynamicism in how people structure projects so this might be too complex. Also it's a pretty minor point.
Part the second
The other possibility would be to detect when people intend a cljs file to be created from the extension. Currently if I type
I get
If Cursive just detected that I typed .cljs it could change the Kind to ClojureScript, but people could change it back if they actually wanted
handlers/cljs.clj
.Part the third
I'm also aware that up and down arrows change the type and maybe I should just use them instead :)
The text was updated successfully, but these errors were encountered: