Skip to content

Olical/clojure-template

Repository files navigation

Clojure template

A starting point for all of my Clojure projects, I hope you will find it useful too. Comes with a fully featured nREPL server, tests, formatter, CI and debugger.

Requires mise to start various tasks which will also handle the Java and Clojure CLI versions for you automatically. Trust me, you'll love it once you try it.

You can use any nREPL based Clojure editor plugins to talk to the REPL but I of course recommend my own, Conjure, if you’re not sure where to start. If you’re really new to Clojure and don’t fancy diving into Neovim then I’d probably recommend Calva.

Fork, copy, clone, borrow, read or browse. Do whatever you want with this repository and use it how you see fit. I like to do the following when starting a new project.

This repository is a GitHub template, so you can create a new repository based on it if you'd like! Or copy the files as shown below.

# Notice the `/.` in order to copy the entire directory and it's hidden directories.
cp -r clojure-template/. my-project
cd my-project
rm -rf .git
git init

Let's stop talking about bike sheds and go paint some instead. Good luck, have fun!

LSP

Make sure you have a LSP client set up for your editor of choice and clojure-lsp installed for the best experience. This will enable extra tooling like linting, in editor formatting, completion and integration with function instrumentation schemas. You can have in editor type checking as you write your Clojure code if you set this up correctly.

Tasks

We use mise to manage the JVM dependency and tasks we can perform on the project.

mise repl

Starts an nREPL server. Before you start working with the project you should run this in a terminal that you can keep safe in the background somewhere.

Evaluate the keyword :dbg in order to open the flowstorm debugger window. How to use flowstorm is outside the scope of this README, but it's worth learning!

mise test

Run the test suite with kaocha. Append --watch to execute your tests as you change files.

mise format

Format all of your code with cljfmt.

mise antq

Find and update dependencies with antq.

# Check for updates
mise antq

# Actually perform updates
mise antq --upgrade

mise clean / build / publish

Handles building and publishing JARs to Clojars.

mise typecheck

Type checking is provided by Typed Clojure, my own typedclojure-lsp is pre-configured in this repository (see .typedclojure-lsp/start), you just need to add the LSP server configuration to your text editor.

GitHub actions

  • Test: Runs the test suite through Kaocha.
  • Typecheck: Checks any marked namespaces with Typed Clojure.

Unlicenced

Find the full unlicense in the UNLICENSE file, but here’s a snippet.

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

About

Opinionated, thorough and up to date starting point for your Clojure projects.

Topics

Resources

License

Stars

Watchers

Forks