Skip to content

Detect/suggest correct Clojure filetype #904

@danielcompton

Description

@danielcompton

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:

  • Use whatever Kind the user last selected (perhaps scoped to this source path)
  • Suggesting file type that majority of sibling files are
  • If a previous source path is /clj or /cljs then choosing that
  • Looking at :cljsbuild/project.clj settings (I'm using bare clojurescript build scripts so this wouldn't apply in my case)
  • If Cursive can't figure it out then just defaulting to .clj (as it seems to now)
  • Perhaps other heuristics too

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

screenshot of intellij idea 27-05-15 10 00 33 am

I get

screenshot of intellij idea 27-05-15 10 00 48 am

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    releasedMarks issues which have had the fixes released in a stable build

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions