Skip to content

Clojure LSPλ︎

Clojure Language Server Protocol LSP

Clojure LSP provides a standard set of features for editing and manipulating source code, e.g. autocompletion, code navigation, refactor code, inline syntax errors and idiom warnings.

LSP and the REPL

The REPL is used to design Clojure effectively by providing instant feedback on code expressions as they are written and evaluated. A REPL based workflow supports the most effective approach to development of Clojure apps and services.

Clojure LSP supports the editing activities to write Clojure code effectively, providing a static analysis of the code base that drives advance editing, navigation and refactor tasks.

Install Clojure LSPλ︎

Many editors that provide an LSP client also manage an install of Clojure LSP

  • Spacemacs with LSP layer enabled
  • Neovim with Mason Plugin

Otherwise download the relevant file from the Clojure LSP Releases.

Clojure LSP Releases

LSP layer configurationλ︎

Adding the lsp layer to .spacemacs will automatically use LSP for Clojure formatting, autocompletion and syntax checking.

LSP will override some features provided by CIDER, so you may wish to configure lsp and lsp UI.

practicalli/spacemacs.d provides an LSP configuration with minimal UI elements and no conflicts with CIDER.

     (lsp :variables
          lsp-ui-doc-enable nil       ;; disable all doc popups
          lsp-ui-sideline-enable nil  ;; disable sideline bar for less distraction
          treemacs-space-between-root-nodes nil) ;; no spacing in treemacs views

Specificationλ︎

The Language Server Protocol (LSP) is a specification for tooling developers, defining a protocol for editors to talk to a language server and provide static analysis features, such as refactoring, symbol navigation, code completion, syntax highlighting.

A standard protocol means an LSP server implementation can support a wide range of tools, reducing the work of editor maintainers and helping ensure common features are available across all editors. LSP does not provide any implementation, this is left to tooling and editor developers.

Referencesλ︎