For environments where the
clj-kondo binary does not run, configure clj-kondo-lsp-server as an language server protocol (LSP) server. This provides the same features as using clj-kondo as a linter.
Example configuration is provided in practicalli/spacemacs.d
Not designed as a full LSP implementation
clj-kondo server only provides static analysis data and is not a full implementation of the Language Server Protocol. Clojure LSP is implementing the Language Server Protocol in full for Clojure and is built on top of the analytic data generated by clj-kondo
A process for each projectλ︎
When opening a Clojure project, a prompt asks if the project should be imported. Every imported project will spawn an LSP process. LSP will remember which projects are imported and spawns an LSP process if Emacs is restarted, adding a few seconds to the startup time.
SPC a p calls the
list-process command which includes all the
clojure-lsp processes if you are concerned about resource usage, although this is very low.
k navigates the list of processes,
d deletes a process and
q quits the process list browser.
Using clj-kondo via LSP shows the text of its messages on the right hand side of the buffer when you move the cursor over an error. When using clj-kondo as a linter, the messages are shown in a popup.
Install and Configure clj-kondo via LSPλ︎
Download the clj-kondo-lsp-server-standalone.jar
Save the clj-kondo jar file to the path to
~/.local/apps/clj-kondo-lsp-server-standalone.jar or preferred location.
Create a script called
clojure-lsp-server-clj-kondo and add the java command to run the LSP server, updating the path to the .jar file if required.
Space f e d to open the Spacemacs configuration file
lsp to the
Add the following code to
(use-package lsp-mode :ensure t :hook ((clojure-mode . lsp)) :commands lsp :custom ((lsp-clojure-server-command '("clojure-lsp-server-clj-kondo"))) :config (dolist (m '(clojure-mode clojurescript-mode)) (add-to-list 'lsp-language-id-configuration `(,m . "clojure"))))
Space f s to save the file and Space q r to restart Emacs. This will download the required packages and load in the LSP configuration in order.