

Clojure and Doom Emacs on a brand new M1 computer
source link: https://www.arthurbrrs.me/clojure-doom-emacs-m1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Clojure and Doom Emacs on a brand new M1 computer
I've recently landed my first Clojure position and received an m1-powered MacBook. Two months before that, I had also bought myself an m1 MacBook air and had to set up Clojure to use it in my projects. Since I had no experience using macOS whatsoever I had to do some googling and managed to get a pretty simple setup running.
There are lots of tutorials out there on how to set up m1 laptops for Clojure usage, but there are a few quirks that aren't yet documented, such as how to get clj-kondo
and parinfer
to work in it. I'll try to cover these steps in this post, while also showing how to set up doom emacs and some other stuff I ended up using myself.
Let's get to it:
Table of contents:
Installing Java and Clojure
This post will describe two ways of installing Java and Clojure: one will use homebrew and the other will install things manually.
Using homebrew:
We'll go the easy route here: we will use Homebrew to install Zulu (an m1 native version of the JVM), Clojure, Java, and Leiningen. To do so, we'll start by adding homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After installing, homebrew will ask us to add it to our PATH. We'll do so and move on to installing Java, Clojure, and Leiningen:
arch -arm64 brew install zulu clojure/tools/clojure leiningen
With the above done, we'll now simply add our JAVA_HOME
to our PATH:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home"
To verify our setup, we can simply run clojure
and open up a REPL.
Manual installation:
We will start by downloading Azul's Zulu m1 build from their downloads page. With the download done, we'll open the zip
file and copy the zulu-17.jdk
folder to /Library/Java/JavaVirtualMachines/
. We'll also set the JAVA_HOME
variable:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home"
With JAVA_HOME
set up, it is time to install Leiningen, which will also install Clojure. To do so, we'll simply follow Leiningen's instructions.
With the above done, we can now verify our setup by running clojure
.
Doom Emacs
My editor of choice is Doom Emacs. To use it, we'll need to first download emacs. This will be done using homebrew:
brew tap railwaycat/emacsmacport
brew install --cask emacs-mac
With the step above done, we'll now move into getting Doom Emacs:
git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d
~/.emacs.d/bin/doom install
Lets now configure it so we can use tools such as CIDER and clojure-lsp. This can be done by changing the .doom.d/init.el
file. We'll start by uncommenting lsp
, and clojure
(under :lang
). We will also want to add +lsp
to that clojure
expression, making it (clojure +lsp)
. Having done that, we'll run ~/.emacs.d/bin/doom sync
and our pretty basic Clojure environment will be set up.
Clj-kondo
Adding +lsp
to clojure
in init.el
made doom add clojure-lsp
to our emacs configuration. Clojure-LSP comes with clj-kondo
, but, for some reason I do not know, flycheck
won't recognize it, so we'll probably also want to install kondo as a separate executable. To do so, we'll need to install GraalVM.
Setting up GraalVM on an m1 device currently requires using a snapshot, so we'll simply use it. Follow this comment to get it up and running. (The file you should download is graalvm-ce-java17-darwin-aarch64-dev.tar.gz
). After setting up, also add the GRAALVM_HOME
variable to PATH
-it should match the value for the JAVA_HOME
for Graal.
We can now compile and install clj-kondo on an m1 device:
git clone https://github.com/clj-kondo/clj-kondo.git
cd clj-kondo
script/compile
Now simply add it to your PATH and you'll be able to use clj-kondo
in flycheck
.
Parinfer-rust
There is currently no releases of parinfer-rust
for m1 devices. This means we need to compile it ourselves. We'll need to install rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
We'll then move into compiling parinfer-rust:
git clone https://github.com/eraserhd/parinfer-rust.git
cd parinfer-rust
cargo build --release --features emacs
After compiling it, we'll move it to emacs:
mkdir ~/.emacs.d/.local/etc/parinfer-rust
mv target/release/libparinfer_rust.dylib ~/.emacs.d/.local/etc/parinfer-rust/parinfer-rust-darwin.so
We'll activate parinfer on our doom config by uncommenting parinfer
in ~/.doom.d/init.el
and adding (use-package! parinfer-rust-mode)
to our ~/.doom.d/packages.el
file and run ~/.emacs.d/bin/doom sync
And that's pretty much it for a basic setup :) Hope someone finds this useful
Recommend
-
97
GitHub is where people build software. More than 28 million people use GitHub to discover, fork, and contribute to over 80 million projects.
-
28
Migrating To Doom Emacs15 Mar 2020Yesterday, I spent some time migrating my vanilla Emacs configuration to Doom Emacs. The whole process took me...
-
12
从Spacemacs迁移到Doom Emacs 发表于 2020-03-26 | 分类于 技术控 | 2 Com...
-
8
Setting Up Gmail in Doom Emacs using mbsync and mu4e I can think of far better ways to spend a quiet Sunday afternoon than trying to get Doom Emacs to serve as an email client, but...
-
8
doom-parents A set of Doom Emacs mappings for manipulating parentheses and sexps Installation ;; ~/.doom.d/packages.el (package! doom-parents :recipe (:host github :repo "tomekw/doom-parents")) ;; ~/.doom.d...
-
7
Starting your Computer Music Journey with Clojure and Overtone in Emacs 8 hours ago2022-04-09T21:30:00+02:00 by Savo Djuric 16 minIn this post I want to write about probably the most powerful...
-
16
最近看了《子弹笔记法》,又想要折腾GTD工作法了。为什么起这个念头呢?那是因为2020都快结束了,而年初的计划根本就没有实现啊,感觉又白白浪费了一年,而我的青春已经所剩无几了(甚至到了连说“青春”两个字都要厚着脸皮的地步)。看了这本书之后,我决心要通...
-
33
在 2021-07-17 org-roam v2 已经正式合并到master分支,已经不用再像本文一样折腾了。 写在前面# org-...
-
10
GadgetsYour Lego Minifigures Can Play Doom by Moving This Motion-Sensing Lego Computer Brick AroundLego is finally add...
-
7
I recently spent some time configuring Doom Emacs to be my email client. It took a lot of trial and error, but I finally have a working configuration. Why did I do this? Because the Emacs...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK