You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/clojure-editors/clojure-lsp/index.md
+100-4Lines changed: 100 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ An editor or plugin provides an LSP client that uses data from language servers,
9
9
10
10
## Clojure LSP
11
11
12
-
[:globe_with_meridians: clojure-lsp](https://clojure-lsp.io/) is an implementation of an LSP server for Clojure and ClojureScript languages. Clojure LSP is built on top of [clj-kondo]() which provides the static analysis of Clojure and ClojureScript code.
12
+
[:globe_with_meridians: clojure-lsp](https://clojure-lsp.io/){target=_blank} is an implementation of an LSP server for Clojure and ClojureScript languages. Clojure LSP is built on top of [:globe_with_meridians:clj-kondo](https://github.com/clj-kondo/clj-kondo){target=_blank} which provides the static analysis of Clojure and ClojureScript code.
13
13
14
14
Most Clojure aware editors provide an LSP client.
15
15
@@ -47,20 +47,116 @@ Check Clojure LSP server is working via the command line
47
47
```
48
48
49
49
50
-
??? HINT "Editors may install Clojure LSP"
50
+
??? HINT "Editors may provide install mechanism for Clojure LSP"
51
51
Spacemacs LSP layer will prompt to install a language server when first opening a file of a major mode where LSP is enabled. E.g. when a Clojure related file is opened, the Clojure LSP server is downloaded if not installed (or not found on the Emacs path).
52
52
53
-
Neovim package called mason manages the install of lint & format tools as well as LSP servers.
53
+
Neovim package called mason manages the install of lint & format tools as well as LSP servers, or an externally installed LSP server can also be used.
54
54
55
55
VSCode Calva plugin includes the clojure-lsp server, although an external server can be configured.
56
56
57
57
58
58
## Configure
59
59
60
+
??? "Practicalli Clojure LSP Configuration"
61
+
[config.edn](https://github.com/practicalli/clojure-lsp-config/blob/main/config.edn) is the recommended configuration from Practicalli.
If not using Java Interop with Clojure, it can be an advantage to disable the Java analysis. This should remove Java functions from autocomplete.
83
+
84
+
```clojure
85
+
:java nil
86
+
```
63
87
88
+
Clean namespace `ns` forms but do not sort require names
89
+
90
+
```clojure
91
+
:clean {:automatically-after-ns-refactortrue
92
+
:ns-inner-blocks-indentation:next-line
93
+
:ns-import-classes-indentation:next-line
94
+
:sort {:nsfalse
95
+
:requirefalse
96
+
:importfalse
97
+
:import-classes {:classes-per-line3} ;; -1 for all in single line
98
+
:refer {:max-line-length80}}}
99
+
```
100
+
101
+
102
+
Use `^private` metadata for private function definitions rather than `defn-`
103
+
104
+
```clojure
105
+
:use-metadata-for-privacy?true
106
+
```
107
+
108
+
Location of [cljfmt configuration](cljfmt.edn) for formatting, path relative to project root. The defaults for cljfmt are used, except `:remove-consecutive-blank-lines?` which is set to false to enable more readable code.
109
+
110
+
```clojure
111
+
:cljfmt-config-path"cljfmt.edn"
112
+
```
113
+
114
+
> [cljfmt configuration](cljfmt.edn) included example `:indents` rules for clojure.core, compojure, fuzzy rules and examples used by the Clojure LSP maintainer.
115
+
116
+
117
+
## Practicalli snippets
118
+
119
+
[Practicalli Snippets](practicalli-snippets.md) are defined in the `:additional-snippets` section of the Practicalli Clojure LSP config.
120
+
121
+
### Docs / comments
122
+
*`comment-heading` - describe purpose of the namespace
123
+
*`comment-separator` - logically separate code sections, helps identify opportunities to refactor to other name spaces
124
+
*`comment-section` - logically separate large code sections with start and end line comments
125
+
*`wrap-reader-comment` - insert reader comment macro, `#_` before current form, informing Clojure reader to ignore next form
126
+
127
+
### Repl Driven Development
128
+
*`rich-comment` - comment block
129
+
*`rich-comment-rdd` - comment block with ignore :redefined-var for repl experiments
130
+
*`rich-comment-hotload` - comment block with add-libs code for hotloading libraries in Clojure CLI repl
131
+
*`wrap-rich-comment` - wrap current form with comment reader macro
132
+
*`require-rdd` - add a require expression, for adding a require in a rich comment block for RDD
133
+
134
+
### Standard library functions
135
+
*`def` - def with docstring
136
+
*`def-` - private def with docstring
137
+
*`defn` - defn with docstring
138
+
*`defn-` private defn with docstring
139
+
*`ns` - namespace form with docstring
140
+
141
+
### Clojure CLI deps.edn aliases
142
+
*`deps-alias` - add Clojure CLI alias
143
+
*`deps-maven` - add a maven style dependency
144
+
*`deps-git` - add a git style dependency using `:git/sha`
145
+
*`deps-git-tag` - as above including `:git/tag`
146
+
*`deps-git-url` - add git style dependency using git url (url taken from dependency name as it is typed - mirrored placeholder)
147
+
*`deps-local` - add a `:local/root` dependency
148
+
149
+
### Requiring dependencies
150
+
*`require-rdd` - add a require expression, for adding a require in a rich comment block for RDD
151
+
*`require` - simple require
152
+
*`require-refer` - require with `:refer`
153
+
*`require-as` - require with `:as` alias
154
+
*`use` - creates a require rather than the more troublesome use
155
+
156
+
### Unit testing
157
+
*`deftest` - creates a deftest with testing directive and one assertion
158
+
*`testing` - creates a testing testing directive and one assertion
159
+
*`is` - an assertion with placeholders for test function and expected results
0 commit comments