Skip to content

Clojure LSP Snippetsλ︎

Tab on the name of the snippet to expand. Tab to jump to additional tab stops.

Clojure LSP snippets appear in the completion popup, in the same way as Clojure functions and other symbols.

Spacemacs LSP snippets - deps snippets in completion menu

Clojure LSP snippets are editor agnostic, usable in any editor that supports clojure-lsp, making them more useful that editor specific snippets.

Clojure LSP snippets are defined using the EDN syntax and supports tab stops, placeholders with default values and can pull in a following form ($current-form).

Built-in snippets are defined in the clojure-lsp.feature.completion-snippet namespace.

practicalli/clojure-lsp-config snippets

Checking available snippetsλ︎

lsp-clojure-server-info function prints the Clojure LSP configuration to the message buffer,

The :additional-snippets top level key contains the user configuration.

clojure-lsp/config.edn
:additional-snippets
[{:name "def-docstring",
  :detail "def with docstring",
  :snippet "(def \"$1\" $0)"}
 {:name "deftest",
  :detail "deftest clojure.test",
  :snippet
  "(deftest ${1:name}-test\n (testing \"${2:Context of the test assertions}\"\n (is (= ${3:assertion-values}))$4))\n $0"}]

:project-settings contain snippets defined in the project .lsp/config.edn file

:project-settings
{:additional-snippets
 [{:name "def-docstring",
   :detail "def with docstring",
   :snippet "(def \"$1\" $0)"}]}