syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

Clojure Mode: Swappable backends (CIDER, inf-clojure, SPIRAL) #11014

Closed mathpunk closed 3 years ago

mathpunk commented 6 years ago

I wouldn't be a Clojure programmer without Spacemacs and CIDER --- the out-of-the-box configuration for jacking into a Clojure project was incredibly helpful for someone who was new not only to the language, but also to the editor and the JVM runtime.

However, as the Clojure ecosystem evolves, the nREPL protocol that CIDER depends on to connect buffers to the REPL is gradually being replaced with the new Socket REPL, and dependents like Unrepl. This means that the default CIDER backend that Spacemacs provides is not compatible with new runtimes like Lumo; it cannot connect with edn-based Socket REPLs one might open up in an application; and it is very challenging to connect it to Figwheel (compare the instructions for a CIDER connection with those of an inf-clojure connection).

I propose that it is time to insert some sort of layer of indirection in the Clojure layer, decoupling CIDER from it. Ideally, beginners could still get the It-Just-Works experience of cider-jack-in, but users who want to connect to Figwheel or Lumo or Socket REPLs could do so, while keeping some or all of the great keybindings for interacting with buffers, tests, and (optimistically) refactoring. Note that SPIRAL is a beta Clojure IDE for Emacs, which might provide some of the functions we'd want.

I did spend part of the afternoon examining the Clojure layer as it is, but I don't have anywhere near the emacs-lisp chops to start figuring out how to make this separation. I want to help, but I don't know how. Is this a project that anyone with better emacs-lisp skills and familiarity with the layer architecture can help with?

mathpunk commented 6 years ago

Addendum: Here is a thread proposing collaboration between the maintainers of CIDER, SPIRAL, and inf-clojure, which I link here in case it helps us see where the seams are between the different IDEs and REPL protocols they use.

mathpunk commented 6 years ago

I think I figured out at least one way that I can contribute: I'm going to try putting the SPIRAL equivalents of the CIDER keybinding definitions I found inside layers/+lang/clojure/packages.el into my user config and see how many equivalents I can find. Something like,

(spacemacs/set-leader-keys-for-major-mode m
            "ha" 'cider-apropos
            "hc" 'clojure-cheatsheet
            "hg" 'cider-grimoire
            "hh" 'cider-doc
            "hj" 'cider-javadoc
            "hn" 'cider-browse-ns
...)

but I think m will have to be either clojure-mode or spiral-mode. It's surprising how long I've been using spacemacs and still haven't really utilized custom keybindings so this will be a good way to find out if I have any major misunderstandings of the process

practicalli-johnny commented 5 years ago

Hello @mathpunk The Spiral project is very interesting and a great example of the future direction of Clojure tooling. Its probably still early days to update the current Clojure layer, however, I do agree that it would be great to have swapable REPL back ends.

Have you considered making a clojure-spiral layer? Either as a personal layer or one shared with the communty?

Creating a clojure-spiral layer (hopefully duplicating most of the existing Clojure layer) would help in the long run when updating the Clojure layer to multi-repl

bbatsov commented 4 years ago

spiral is already defunct today, but I guess the idea is reasonable in general. Besides inf-clojure and CIDER, there's also monroe, which is still active. There's no shortage of Clojure development environments for Emacs. :-)

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!