• Stars
    star
    326
  • Rank 129,027 (Top 3 %)
  • Language
    Clojure
  • License
    Eclipse Public Li...
  • Created almost 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fertile ground for Clojure tooling

CircleCI Coverage Clojars Project cljdoc badge downloads badge

Orchard

A Clojure library designed to provide common functionality for Clojure development tools (e.g. Clojure editor plugins and IDEs).

Right now orchard provides functionality like:

  • enhanced apropos
  • classpath utils (alternative for java.classpath)
  • value inspector
  • Java class handling utilities
  • Utilities for dealing with metadata
  • Namespace utilities
  • Fetching ClojureDocs documentation
  • Finding function dependencies (other functions invoked by a function) and usages

Why?

Much of the tooling code required to build Clojure editors and smart REPLs is tool-agnostic and should be reused between tools, instead of copied and altered in each and every tool.

Having a common tooling foundation typically means:

  • Better foundation (e.g. more functionality, good documentation, etc) with more contributors
  • Less work for tool authors as they don't have to reinvent the wheel for every tool
  • Happier end users

Design

Orchard is meant to be used to build programmer tooling relying on inspecting the state of a running REPL. REPL-powered tooling has been a core Lisp idea for many years and there are many Clojure libraries in that space (e.g. compliment, tools.trace, sayid, etc).

One thing to keep in mind is that Orchard relies (mostly) on runtime information, not the source code itself. In simple terms - only code that's loaded (evaluated) will be taken under consideration. That's pretty different from the static analysis approach taken by tools for most programming languages where it's not possible to easily inspect the state of running program.

Some other design goals are listed bellow.

No Runtime Dependencies

Orchard is meant to run alongside your application and we can't have a dev tools library interfere with your app right? Dependency collisions are nasty problems which are best solved by making sure there can't be any shared libraries to cause the conflict.

API Optimized for Editors

Code editors can't know what symbols resolve to without consulting a REPL that's why they would typically send a combination of a symbol name and some ns (e.g. the current namespace), so they can be resolved to some var on which an operation would be invoked.

That's why the majority of the functions in Orchard take a combination of a ns and a symbol instead of a var. Probably down the road we'll provide var-friendly versions of most functions as well.

REPL Agnostic

No matter whether you're using nREPL, a socket REPL, unrepl or prepl, Orchard has your back. nREPL clients might opt to wrap some of the Orchard functionality in middleware for convenience (as cider-nrepl does), but they can just eval away if they please.

API Documentation

Documentation for the master branch as well as tagged releases are available here.

Usage

orchard requires Clojure 1.8+ and Java 8+.

Just add orchard as a dependency and start hacking.

[cider/orchard "0.13.0"]

Consult the API documentation to get a better idea about the functionality that's provided.

Using enrich-classpath for best results

There are features that Orchard intends to provide (especially, those related to Java interaction) which need to assume a pre-existing initial classpath that already has various desirable items, such as the JDK sources, third-party sources, special jars such as tools (for JDK8), a given project's own Java sources... all that is a domain in itself, which is why our enrich-classpath project does it.

For getting the most out of Orchard, it is therefore recommended/necessary to use enrich-classpath. Please refer to its installation/usage instructions.

xref/fn-deps and xref/fn-refs limitations

These functions use a Clojure compiler implementation detail to find references to other function var dependencies.

You can find a more in-depth explanation in this post.

The important implications from this are:

  • very fast
  • functions marked with meta :inline will not be found (inc, +, ...)
  • redefining function vars that include lambdas will still return the dependencies of the old plus the new ones (explanation)
  • does not work on AoT compiled functions

Configuration options

So far, Orchard follows these options, which can be specified as Java system properties (which means that end users can choose to set them globally without fiddling with tooling internals):

  • "-Dorchard.initialize-cache.silent=true" (default: true)
    • if false, the class info cache initialization may print warnings (possibly spurious ones).

Tests and formatting

To run the CI tasks locally use:

make test cljfmt kondo eastwood

History

Originally SLIME was the most popular way to program in Clojure with Emacs and a lot of useful functionality was created for it to support things like code completion, value inspection, finding references, apropos and so on. This functionality was implemented as a swank adapter written in Clojure and lived in the swank-clojure project.

Subsequently CIDER and cider-nrepl replaced SLIME and swank, and much code was moved from swank-clojure to cider-nrepl and continued to evolve there.

You can watch the presentation The Evolution of the Emacs tooling for Clojure to learn more about all of this.

This project is an effort to prevent repeating the mistakes of the past - cider-nrepl was split into two libraries, so that non-nREPL clients can make of use of the general functionality contained in cider-nrepl (e.g. things like apropos, inspect, etc).

Development

You can install Orchard locally like this:

PROJECT_VERSION=0.13.0 make install

...note that projects such as cider-nrepl or refactor-nrepl use copies of Orchard that are inlined with mranderson, so a local Orchard install won't automatically update those.

For releasing to Clojars:

git tag -a vX.Y.Z -m "Release X.Y.Z"
git push --tags
git push

License

Copyright Β© 2018-2022 Bozhidar Batsov & contributors

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

More Repositories

1

cider

The Clojure Interactive Development Environment that Rocks for Emacs
Emacs Lisp
3,539
star
2

clojure-mode

Emacs support for the Clojure(Script) programming language
Emacs Lisp
909
star
3

clj-refactor.el

A CIDER extension that provides powerful commands for refactoring Clojure code.
Emacs Lisp
771
star
4

cider-nrepl

A collection of nREPL middleware to enhance Clojure editors with common functionality like definition lookup, code completion, etc.
Clojure
673
star
5

sayid

A debugger for Clojure
Clojure
406
star
6

refactor-nrepl

nREPL middleware to support refactorings in an editor agnostic way
Clojure
257
star
7

inf-clojure

Basic interaction with a Clojure subprocess
Emacs Lisp
249
star
8

squiggly-clojure

Flycheck checker for Clojure, using eastwood and core.typed.
Emacs Lisp
204
star
9

clomacs

Simplifies Emacs Lisp interaction with Clojure and vice versa.
Emacs Lisp
200
star
10

clojure-cheatsheet

[DEPRECATED] The Clojure Cheatsheet for Emacs
Emacs Lisp
193
star
11

clojure-ts-mode

The next generation Clojure major mode for Emacs, powered by TreeSitter
Emacs Lisp
129
star
12

clj-suitable

ClojureScript "IntelliSense" support for JS objects and their properties/methods. Via figwheel and Emacs CIDER.
Clojure
114
star
13

ac-cider

[DEPRECATED] Emacs auto-complete backend for CIDER
Emacs Lisp
80
star
14

ac-nrepl

[DEPRECATED] Emacs auto-complete backend for nrepl completions
Emacs Lisp
74
star
15

helm-cider

Helm interface to CIDER
Emacs Lisp
66
star
16

parseclj

Clojure Parser for Emacs Lisp
Emacs Lisp
60
star
17

cljs-tooling

[DEPRECATED] Tooling support for ClojureScript
Clojure
60
star
18

parseedn

EDN parser for Emacs Lisp
Emacs Lisp
59
star
19

example-config

A sample Emacs config for Clojure development to ease your pain
Emacs Lisp
37
star
20

haystack

Let's make the most of Clojure's infamous stacktraces!
Clojure
34
star
21

enrich-classpath

Enriches Lein/deps.edn dependency trees with Java sources, JDK sources, javadocs, etc
Clojure
32
star
22

cider-decompile

An extension to CIDER which provides a decompilation command
Emacs Lisp
27
star
23

cider-hydra

Hydras for CIDER
Emacs Lisp
24
star
24

cider-eval-sexp-fu

eval-sexp-fu.el extensions for CIDER.
Emacs Lisp
12
star
25

hackingcider

HTML
10
star
26

clojuredocs-export-edn

Daily EDN exports of ClojureDocs's database.
Clojure
9
star
27

logjam

An interactive, nrepl-oriented logging backend
Clojure
1
star
28

docs.cider.mx

CIDER's documentation site
Handlebars
1
star