Skip to content

Commit bc9227c

Browse files
editor: update Clojure LSP page and included Practicalli Clojure LSP Config via external url
Resolve: #464
1 parent 14d7739 commit bc9227c

2 files changed

Lines changed: 101 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- install: debian packages approach for OpenJDK rather than a specific Ubuntu tab
1111
- install: recommended OpenJDK versions of 17 and 21 as hint
1212
- editor: refactor Clojure LSP page and format for Material for MkDocs
13+
- editor: update Clojure LSP page and included Practicalli Clojure LSP Config via external url
1314

1415
## Added
1516
- button link to Clojure CLI releases changelog to view available versions

docs/clojure-editors/clojure-lsp/index.md

Lines changed: 100 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ An editor or plugin provides an LSP client that uses data from language servers,
99

1010
## Clojure LSP
1111

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.
1313

1414
Most Clojure aware editors provide an LSP client.
1515

@@ -47,20 +47,116 @@ Check Clojure LSP server is working via the command line
4747
```
4848

4949

50-
??? HINT "Editors may install Clojure LSP"
50+
??? HINT "Editors may provide install mechanism for Clojure LSP"
5151
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).
5252

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.
5454

5555
VSCode Calva plugin includes the clojure-lsp server, although an external server can be configured.
5656

5757

5858
## Configure
5959

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.
62+
```clojure
63+
--8<-- "https://raw.githubusercontent.com/practicalli/clojure-lsp-config/main/config.edn"
64+
```
6065

66+
Include `:extra-paths` and `:extra-deps` from project & user level aliases in LSP classpath. e.g. support a custom `user` namespace in `dev/user.clj`
6167

62-
??? "Practicalli Clojure LSP Configuration"
68+
```clojure
69+
:source-aliases #{:dev :test :env/dev :env/test :lib/reloaded}
70+
```
71+
72+
Include Java Sources installed via Debian / Ubuntu package `openjdk-21-source` to support calls to Java Objects and Methods.
73+
74+
```clojure
75+
:java
76+
{:jdk-source-uri "file:///usr/lib/jvm/openjdk-21/lib/src.zip" ;;
77+
:home-path nil ;; jdk-source-uri takes precedence
78+
:download-jdk-source? false}
79+
```
80+
81+
!!! HINT "Disable Java analysis"
82+
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+
```
6387

88+
Clean namespace `ns` forms but do not sort require names
89+
90+
```clojure
91+
:clean {:automatically-after-ns-refactor true
92+
:ns-inner-blocks-indentation :next-line
93+
:ns-import-classes-indentation :next-line
94+
:sort {:ns false
95+
:require false
96+
:import false
97+
:import-classes {:classes-per-line 3} ;; -1 for all in single line
98+
:refer {:max-line-length 80}}}
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
64160

65161

66162
## References

0 commit comments

Comments
 (0)