This package integrates clj-kondo with Emacs via flycheck.
Before installing the Emacs package, make sure the clj-kondo
is on your
path. For installation instructions, see https://github.com/borkdude/clj-kondo.
Install from MELPA:
M-x package-install flycheck-clj-kondo
Then add the following to your init.el:
(require 'flycheck-clj-kondo)
Install via use-package:
;; First install the package:
(use-package flycheck-clj-kondo
:ensure t)
;; then install the checker as soon as `clojure-mode' is loaded
(use-package clojure-mode
:ensure t
:config
(require 'flycheck-clj-kondo))
Install via el-get:
(el-get-bundle flycheck-clj-kondo
:url "https://raw.githubusercontent.com/borkdude/flycheck-clj-kondo/master/flycheck-clj-kondo.el"
(require 'flycheck-clj-kondo))
To set up multiple linters, e.g. in combination with flycheck-joker, add this after you required the linter packages:
(dolist (checker '(clj-kondo-clj clj-kondo-cljs clj-kondo-cljc clj-kondo-edn))
(setq flycheck-checkers (cons checker (delq checker flycheck-checkers))))
This ensures that the clj-kondo checkers are the first ones in the flycheck-checkers
list. This is needed to make the chain work. To create the chain, also add the following code:
(dolist (checkers '((clj-kondo-clj . clojure-joker)
(clj-kondo-cljs . clojurescript-joker)
(clj-kondo-cljc . clojure-joker)
(clj-kondo-edn . edn-joker)))
(flycheck-add-next-checker (car checkers) (cons 'error (cdr checkers))))
To lint across namespaces in a project, clj-condo needs a directory to store cached data. Create a .clj-kondo
directory and lint the entire classpath from the command line.
Make sure Eldev is installed and
run eldev test
for testing, eldev lint
for linting.
Check your PATH according to Emacs: M-x shell
, then echo $PATH
. If there are any differences between that PATH and the one you are able to run clj-kondo from (e.g., your PATH according to Terminal on macOS), add them by including them in your Emacs config. For example, if you needed to include /usr/local/bin
, you could add to init.el:
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
(setq exec-path (append exec-path '("/usr/local/bin")))
Then, restart Emacs.