r/Clojure • • 10d ago

Capstan - IntelliJ IDEs Plugin

https://plugins.jetbrains.com/plugin/36234-capstan

Clojure developers who prefer JetBrains IDEs have long had two main options. One is the commercial Cursive plugin. The other is clojure-lsp-intellij together with LSP4IJ. Capstan is a third option, now on the JetBrains Marketplace. It's a free plugin that adds Clojure and ClojureScript support to IntelliJ IDEA. It is modeled on Calva, the popular VS Code extension, and it is written in Clojure.

Structural Editing: Calva's Paredit

Structural editing matters a lot in any Lisp. Capstan ports Calva's paredit commands, and its description says all 435 of Calva's paredit test cases pass. Along with the usual slurp, barf, splice and raise commands, it includes:

  • a strict mode that keeps brackets balanced;
  • formatting with cljfmt;
  • code folding by form;
  • highlighting for forms commented out with #_;
  • an Extend Selection that grows one form at a time.

If you are coming from Calva, editing should feel the same.

Its Own clojure-lsp Client

The biggest change in version 1.6.0 is that Capstan no longer depends on LSP4IJ. It now has its own clojure-lsp client. Capstan downloads the latest clojure-lsp for you, or you can point it at a binary you already have. The language features include:

  • diagnostics, completion and navigation;
  • find usages and rename;
  • documentation, code actions and parameter info;
  • usage highlighting, a structure view and Go to Symbol;
  • call hierarchy, reference counts and semantic highlighting.

clojure-lsp's refactorings also appear in the IDE's Refactor menu.

There are also features for reliability. A status bar widget shows the server state, and a separate tool window shows the logs. If the server crashes, Capstan restarts it. If a newer clojure-lsp fails to start, Capstan goes back to the previous version that worked.

nREPL: Interactive Development

Capstan can jack in with one action for deps.edn, Leiningen, shadow-cljs, babashka and nbb projects. Evaluation results appear inline next to your code. The REPL window has completion and pretty-printing, stack traces are clickable, and ClojureScript sessions work too. Since version 0.1.4, REPL output is also written to .capstan/repl-output.log in the project. Color codes are removed, and the log rotates once it passes 10 MB. The folder tells git to ignore it, so it stays out of your commits.

Testing and Debugging

clojure.test results show up in the IDE's own test tree. For failed tests you can compare expected and actual values, and you can rerun only the failures. The debugger connects cider-nrepl's debugging to IntelliJ's debugger UI. You can set line breakpoints, step through code, inspect local variables and evaluate expressions at a breakpoint, much like debugging Java.

Keybindings Under Prefixes

Capstan puts its shortcuts under two prefix keys, so they don't take over IntelliJ's own:

Alt+N for the REPL, tests and the debugger;

Alt+K for paredit.

If you want Calva's one-key shortcuts instead, you can switch to the optional "Capstan (Calva)" keymap. To see every shortcut, open Settings → Keymap and search for "Capstan".

5 Upvotes

4 comments sorted by

1

u/geokon 10d ago

Is this open source?

0

u/TTalkIM 10d ago

No it isn't a open source plugin. It's a freeware.

1

u/geokon 1d ago edited 1d ago

running a closed source plugin these days seems insane (esp with no reputation or legal name attached to it). It'd at least look in to making it source-available. For what its worth, I think realistically the market is too small to commercialize a Clojure extension.

Btw, how it is the Clojure community in China? Are there Clojure forums? I spend part of the year in Chengdu, but I assume if it exists it's probably in Shenzhen/Shanghai :)

2

u/TTalkIM 10h ago edited 9h ago

We don't have may Clojure communities and jobs. Clojure is a niche culture in China. I don't open source the plugin because it share some code from our code base, so we keep it closed source and a freeware. Even our company very small, but we keep using Clojure to write software to reduce the complex in Java world and we just want to share our work with Clojure users in the world, even the world is full of Agents. We use this plugin, Clojure, ClojureScript, C++ , GLM and KIMI build https://apps.microsoft.com/detail/9pcqwskm05c1?hl=en-US&gl=US and https://apps.microsoft.com/detail/9p82nv1s592z?hl=en-US