Skip to content

Commit 249db16

Browse files
draft: clojure coding is easy with neovim
1 parent 346939c commit 249db16

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: Clojure Coding is easy with Neovim
3+
date:
4+
created: 2025-03-12
5+
updated: 2025-03-12
6+
authors:
7+
- practicalli
8+
categories:
9+
- practicalli
10+
tags:
11+
- clojure
12+
- neovim
13+
- conjure
14+
- astronvim
15+
draft: true
16+
---
17+
18+
TODO: Add pictures and a video
19+
20+
21+
<!-- more -->
22+
23+
## Install Clojure
24+
25+
Java and Clojure CLI and Practicalli Clojure CLI Config
26+
27+
## Install Neovim
28+
29+
Latest stable Release
30+
31+
## Configure Neovim
32+
33+
Start with Practicalli Astro as your configuration, to give a rich set of (lazy loading) features.
34+
35+
First run of Neovim will install the relevant packages.
36+
37+
## Clojure workflow
38+
39+
Start a REPL in the root of the Clojure project. The `:repl/rebel` alias also runs an nREPL server which an editor uses to communicate with the REPL process.
40+
41+
```shell
42+
clojure -M:repl/rebel
43+
```
44+
45+
Open a Clojure file from the project with Neovim (or evaluate code from an already open Clojure file)
46+
47+
```shell
48+
nvim src/practicalli/gameboard/service.clj
49+
```
50+
51+
> Or open Neovim, `nvim .` and use `SPC f f` to find a file or navigate the project directory tree with neogit buffer.
52+
53+
Evaluate some Clojure code to connect the editor to the REPL process over nREPL.
54+
55+
++comma+ ++"e"++ ++"b"++ Evaluate the file (buffer)
56+
57+
++comma+ ++"e"++ ++"r"++ to evaluate from the top-level (root) of an expression, e.g. the `ns` expression.
58+
59+
Evaluation results will show inline.
60+
61+
++comma+ ++"e"++ ++"c"++ menu to evaluate results as comments.
62+
63+
++comma+ ++"l"++ ++"t"++ to open the REPL buffer in a tab page and see the whole REPL history.
64+
65+
> NOTE: Code can also be evaluated in the REPL buffer (although its far easier to evaluate the source code buffers).
66+
67+
## Diagnostics and Refactor tools
68+
69+
Clojure LSP is included in the Practicalli Astro configuration, via the Mason plugin which manages LSP servers, DAP servers, lint and format tools. Mason registry tracks the latest release of each tool.
70+
71+
Warning and Error icons are show in the margin of respective line of code.
72+
73+
++g++ ++d++ jumps to the definition of a function (even those in jar files)
74+
75+
++spc++ ++l++ LSP menu includes code actions, renaming, symbol outlines, etc
76+
77+
!!! TIP "Clojure LSP can also format code"
78+
Clojure LSP includes cljfmt library to format code using the recommendations in the Clojure Style Guide.
79+
80+
81+
## Running tests
82+
83+
++,++ ++t++ Testing menu has commands to start a test runner over one or more tests evaluated in the REPL.
84+
85+
Practicalli Astro uses Kaocha test runner, although others are easily configured.
86+
87+
88+
## Source Control
89+
90+
The ++spc++ ++"g"++ menu has commands to stage the current hunk or all changes in the current buffer (Git Signs plugin).
91+
92+
Git Signs also shows differences in working copy and committed code.
93+
94+
Neogit (an Emacs Magit clone) and LazyGit clients will stage/unstage, push, pull and rebase code, providing all the common git commands via a terminal UI.
95+
96+
> NOTE: LazyGit binary should be installed and available on the operating system path.
97+
98+
---
99+
Thank you.
100+
101+
[:globe_with_meridians: Practical.li Website](https://practical.li){target=_blank .md-button}
102+
103+
[:fontawesome-brands-github: Practical.li GitHub Org](https://github.com/practicalli){target=_blank .md-button}
104+
[:fontawesome-brands-github: practicalli-johnny profile](https://github.com/practicalli-johnny){target=_blank .md-button}
105+
106+
[:fontawesome-brands-mastodon: @practicalli@clj.social](https://clj.social/@practicalli){target=_blank .md-button}
107+
[:fontawesome-brands-twitter: @practical_li](https://twitter.com/practcial_li){target=_blank .md-button}

0 commit comments

Comments
 (0)