Skip to content

Clojure LSP snippetsλ︎

Clojure LSP contains several built-in snippets. The practicalli/clojure-lsp-config repository enhances and extends the available snippets, helping create code that documents its purpose clearly.

Practicalli Snippets for Clojure LSP

Install Practicalli Clojure LSP snippetsλ︎

practicalli/clojure-lsp-config contains a wide range of snippets for Clojure LSP, some of which were contributed to the Clojure LSP project

Clone via SSH

git clone -o practicalli $XDG_CONFIG_HOME/clojure-lsp

Clone via HTTPS

git clone -o practicalli $XDG_CONFIG_HOME/clojure-lsp

Clone via SSH

git clone -o practicalli $HOME/.clojure-lsp

Clone via HTTPS

git clone -o practicalli $HOME/.clojure-lsp

Clojure LSP should automatically pick up the new changes without having to restart.

Restart LSP Workspace

, b r will restart the current LSP workspace in the event snippets are not showing

Using snippetsλ︎

Start typing the name of the snippet and it should appear in the auto-completion pop-up menu. Matching entry names end with (Snippet).

Spacemacs Clojure LSP snippets - comment example

Enter to expand the highlighted snipped

Tab / Ctrl+j & Ctrl+k or arrow-keys navigate the auto-completion pop-up list when there are multiple entries.

Adding custom snippetsλ︎

Edit the config.edn file.

The :additional-snippets key has a collection of hash-maps, with each hash-map representing a snippet.

$n represents a tab-stop, where the TAB key will jump throughout the snippet. n is an integer number to define the order of the tab-stops, e.g. $1, $2, $3.

$0 is a special tab-stop that denotes the end of the tab-stops, ending the snippet interaction.

${n:placeholder text} allows text to be placed at the tab-stop to give an indication as to the value to be completed. The placeholder text is automatically highlighted when tabbing into the tab-stop, so typing a new value replaces the placeholder text.

Highlighting and replacing the text does not work for the $0 tab-stop, so placeholder text should not be used with this specific tab-stop.

Last update: December 19, 2022