Cursive 1.8.0

328 views
Skip to first unread message

Cursive

unread,
Nov 22, 2018, 4:41:44 AM11/22/18
to cur...@googlegroups.com

Hi everyone,

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:

Macrovich fix doesn’t work for mount because of vendoring #2086
Add support for :extend-via-metadata in protocol definitions #2085
Resolution cannot be customised from library code #2084
Do not require resolution customisation targets to be present in project #2081
cljs-out directory should be excluded #2080
Adding :local/root dependencies in tools-deps support errors-out if the referenced project doesn’t have the same aliases #2075
Deps-based repl doesn’t appear to properly setup env vars #2072
tools.deps does not handle CWD not being set correctly #2065
Allow creating deps REPLs via right-click, similar to lein #2064
Error with deps integration: ExternalSystemException: Couldn’t read <file><file> (No such file or directory) #2062
Stubs generation is broken in 1.8.0-eap7 #2061
Cursive doesn’t handle namespaced maps in deps.edn files #2060
Add -r at end of parameters rather than beginning #2059
macros not always resolved #2053
Refactoring keywords creates incorrect values #2051
environment variables defined using environ.core are not propagated to program when using trampoline #2050
Run configs fail due to proxy exceptions problem #2049
Add support for IntelliJ 2018.3 EAP #2046
Files from dependency modules cannot be loaded into deps.edn REPL #2039
Add autocomplete to deps.edn files #2036
Allow deps to be added with “Generate…” action #2034
New local REPL should auto select module if only one in project #2033
When starting local REPL types, empty console window is always shown. #2031
Allow paths out of content root when using deps #2030
Deps auto-import doesn’t work #2025
Deps toolwindow sometimes doesn’t appear #2024
Windows: exception generating stubs when classpath is too long, CreateProcess error=206 #2021
Allow using tools.deps directly #2019
Deps support should support fully qualified aliases #2017
tools.deps timeout for clojure executable when classpath is stale #2012
deps.edn: Can’t read resource from paths entry #2010
IndexNotReady exception on project open #1996
“Cannot switch to ClojureScript namespace in Clojure REPL” for cljs > 1.10.63 #1993
com.intellij.openapi.project.IndexNotReadyException: Please change caller accord #1985
Request: config to use two semicolons ;; for line comments #1983
Symbol resolution doesn’t work from definition, only from usage #1977
BUG Reformatting breaks reader conditionals in require form when using parinfer #1972
Locals clearing setup on REPL start doesn’t work with cljs.main #1955
Support for deps.edn #1910
Add support for macrovich? #1847
Keywords suggestion are twisted if two or more project/editors are open simultaneously #1581
Fuzzy search for keywords #1439
Feature Request: Folding code and data #1269
Having trouble with finding relative certificates from project.clj #1156
Hangs on REPL Start: Error when starting java process due to length of classpath #1150
Allow “lein run” option to run a REPL #1036
ns formatting with reader conditionals #1014
Schema defmethod #993
StackOverflowError in CLJS code #929
ToolWindow icons should be 13x13 #456

Cheers,
Colin

Alan Moore

unread,
Nov 22, 2018, 12:22:38 PM11/22/18
to cur...@googlegroups.com
Damn... that’s a lot of stuff! Congratulations on this excellent release. Thanks for all your hard work!

Alan
--
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.

Colin Fleming

unread,
Nov 23, 2018, 4:01:22 AM11/23/18
to cur...@googlegroups.com
Hehe, yes, sorry for the wall of text - I'm working on the doc to get it all in there!

Thanks for the kind words and all your support, as always.

Cheers,
Colin
Reply all
Reply to author
Forward
0 new messages