r/Clojure • • 2d 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

2 comments sorted by

1

u/geokon 2d ago

Is this open source?

-1

u/TTalkIM 2d ago

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