Cursive 1.8.0 is out at last!
The main new feature is support for managing project dependencies with Clojure’s new deps.edn. I’m currently working on full documentation for this which should be available shortly, but hopefully it will work in a similar way to existing integrations so it should feel familiar.
The project creation flow has changed slightly, now when creating a new project you need to select Clojure in the left-hand pane, and then within that you can select from different project types. The available options are now Leiningen, Deps and a simple project with no dependency management, but in the future I’m considering some others like shadow-cljs and a cljs-quickstart project.
Similar to the lein integration, you can choose which aliases you want to use when syncing your project to IntelliJ. This means that you can ensure that things like dev dependencies and extra paths are synced. As with the Lein support, this is controlled in the deps toolwindow. There’s also an IDE level setting for the default aliases which you’d always like selected in new projects (e.g. test).
As with the Leiningen integration dependencies can be added to deps projects using the “Generate…” action, which means you can add Maven dependencies with auto-complete from anywhere in your project.
Here’s a list of potential gotchas or problems:
When creating inter-project dependencies using :local/root, Cursive will create a library rather than a module dependency. This is because deps is unusual in how things like source paths are propagated from dependent projects to the root ones.
Deps also has no concept of the name of a project in the deps file, so there’s nothing for Cursive to be able to derive a module name from. Currently it just uses the name of the containing directory, but since module names must be unique this will be a problem if you have something like server/api and client/api.
Similarly, the only reasonable thing to call the library used for a :local/root dep is the name of the symbol used to declare it in the deps.edn file. But if two separate projects reference the same dependency using different names then two separate libraries will be created pointing to the same sources.
The IntelliJ build system API which the deps support is based on has a concept of “linked projects”, which are projects managed via build files which you’ve registered with the IDE. The lein integration works like the Maven integration does, i.e. you need to register all the project.clj files which are part of your project. This new API only supports systems more like the Gradle integration which is based on the same API I’m using. Here, you only register the root project with the IDE, and the subprojects (:local/root dependencies in deps) are discovered and added automatically.
On systems which support the CLI tools (e.g. Mac & Linux) Cursive will use those by default. On Windows, which doesn’t have CLI tools as of the time of this writing, you can choose instead to use the tools.deps library directly. This has some caveats, in particular the system deps.edn is bundled with Cursive, so it will always use the current version as of the time of this writing. There is some consideration being given to bundling that into the tools.deps jar rather than installing it via the CLI tools, if that happens this limitation will go away.
The configuration of this is currently a little clunky. You can configure it either at Settings->Build, Execution, Deployment->Build Tools->Clojure Deps or in the global settings section when setting up a new project. Select “Use tools.deps directly”, then press the “Refresh” button to get the list of available versions. Select the version you want to use (by default the latest is selected) and then press “Download” to fetch the artifacts from Maven. If required, you can also customise the path to your user deps.edn file if you want to do so.
Note that this doesn’t require or use WSL at all, and in fact it can’t - IntelliJ lives entirely in Windows land and can only read files from WSL. If you’ve been using deps under WSL you’ll probably have to copy your user deps.edn somewhere accessible, or point Cursive to it as described above. Any feedback about how well all this works is very welcome.
Cursive will try to create tasks for the various aliases that are registered with runtime options in deps files, however support for these is currently experimental at best.
As part of adding support for deps, running Clojure scripts and REPLs has been restructured to separate out what you’re running from how you’re running it. So for Clojure scripts, you choose whether to run a -main function from a namespace or a script file, and then you select whether to run it using the IntelliJ project classpath, using Leiningen or using deps. Similarly for REPLs you now choose whether you want to run an nREPL REPL or a clojure.main one, and choose which of the same execution options to use. Your existing run configurations should be migrated to the new format automatically.
There are also many smaller new features. There’s now an option to use double semicolons for line comments, for Emacs compatibility. It can be turned on using Editor->General->Smart Keys->Clojure->Use ;; for line comments. Code folding is now a bit smarter and allows regions to be manually specified using comments. Data structures in EDN files can also be folded, and Cursive will try to be a bit clever about how the folded summaries look.
There is now a new Navigate->Keyword… action. This will allow you to search for keywords in the current project by name, narrowing down on typing as usual. When you select one you’ll get the standard show usages popup, which will allow you to navigate to the usage you’re interested in.
Also, when customising symbol resolution and choosing the Specify… option, Cursive used to show a list of all known vars in the project to select from. This had two main problems: it was not possible to select some built in forms such as do, and it was not possible to select vars which were not present in your project. For example, if you had a new macro which looks like a re-frame one but you did not have re-frame added to your project, you could not select the re-frame macro to customise as even though that support is built into Cursive regardless. Now, when customising, instead of using the vars in the project Cursive will now present a list of all the known macros you can resolve as, which fixes both these problems.
Some important bugs have been fixed. A long-standing bug with command line lengths has been fixed at last: On some platforms (particularly the W one) commands can only be up to a certain length. This can be a problem for extremely long classpaths. IntelliJ now allows long command line paths like this to be shortened using various tricks. This can now be controlled for REPL run configs and running Clojure scripts using the “Shorten command line” option in their run configuration screens. This issue can also affect stub generation, and can be controlled per-module for that in File->Project Structure->Modules->[your module]->Clojure. For both of these options, you probably want to select “classpath file”. This change requires functionality in the IntelliJ platform from the 2017.3 release, so it’s not available in IntelliJ versions prior to that.
Previously local REPL run configurations would always open a useless empty console window, this is now fixed (via a hack, check the issue for details).
I also fixed a long-standing problem in keyword completion where Cursive would suggest keywords which appear in other open projects, and also keywords which had been recently deleted. This was really annoying after misspelling a keyword since the misspelling would persist in completions for a significant amount of time.
And finally, this release also adds support for the new IntelliJ 2018.3. Since 2018.3 is now GA, this will be the last Cursive release with support for 2016.2 ad 2016.3.
In addition to all this there are many more small bug fixes and new features - see the issue list for details.
Here are the issues:
You received this message because you are subscribed to the Google Groups "Cursive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cursive+u...@googlegroups.com.
To post to this group, send email to cur...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/1243495105.1.1542879702050.JavaMail.colin%40MacBook-Pro.localdomain.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/CA%2BE19F2ELiBaU%3D1xR0kpYYoj7goDEyC3fkxMa2SYzpzoUy12uw%40mail.gmail.com.