Skip to content

Commit e1ab450

Browse files
committed
Prepare for next release
- dogfood launchpad - experimental LSP integration(ish) - start watcher in background thread - include `:deps` from `deps.local.edn` in inital boot
1 parent f28830c commit e1ab450

File tree

9 files changed

+56
-11
lines changed

9 files changed

+56
-11
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ resources/public/ui
1212
.store
1313
out
1414
.#*
15+
.clj-kondo
16+
.lsp/.cache

.lsp/config.edn

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{:project-specs [:classpath-cmd ["cat" ".cpcache/launchpad.edn"]]}

CHANGELOG.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
## Added
44

5+
- Write the current classpath to `.cpcache/launchpad.cp`, for integrating third
6+
parties like clojure-lsp. (configure `cat .cpache/launchpad.cp` as your
7+
`:classpath-cmd`)
8+
- Call `(user/go)` in a `try/catch`
9+
- Start the watcher on a separate thread, it can take a long time to boot, and
10+
meanwhile we shouldn't block REPL startup.
11+
512
## Fixed
613

7-
## Changed
14+
- Pick up any `:deps` from `deps.local.edn` at startup, not at the first
15+
classpath reload
816

917
# 0.11.59-alpha (2022-10-21 / 8454771)
1018

@@ -90,4 +98,4 @@ Initial release
9098
- lambdaisland.classpath integration
9199
- Support for cider-nrepl, refactor-nrepl
92100
- Basic support for shadow-cljs cljs nREPL-base REPL
93-
- Auto-connect for Emacs
101+
- Auto-connect for Emacs

bb.edn

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{:deps
22
{lambdaisland/open-source {:git/url "https://github.com/lambdaisland/open-source"
33
:sha "7f39ffb76d47e2ff83d4478957c2ca4fd180f3e5"
4-
#_#_:local/root "../open-source"}}}
4+
#_#_:local/root "../open-source"}
5+
com.lambdaisland/launchpad {:local/root "."}}}

bin/launchpad

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bb
2+
(ns transit.dev-repl.main
3+
(:require [lambdaisland.launchpad :as launchpad]))
4+
5+
(launchpad/main {})

deps.edn

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
:deps
44
{org.clojure/clojure {:mvn/version "1.11.1"}
5-
com.lambdaisland/dotenv {:mvn/version "0.1.1"}}
5+
com.lambdaisland/dotenv {:mvn/version "0.2.5"}}
66

77
:aliases
88
{:clojure { :extra-deps {babashka/babashka {:mvn/version "1.0.164" :scope "provided"}
@@ -16,4 +16,4 @@
1616

1717
:test
1818
{:extra-paths ["test"]
19-
:extra-deps {lambdaisland/kaocha {:mvn/version "1.70.1086"}}}}}
19+
:extra-deps {lambdaisland/kaocha {:mvn/version "1.71.1119"}}}}}

src/lambdaisland/launchpad.clj

+11-2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158
:else
159159
b))
160160
deps-edn deps-local))
161+
;; Pull these out and inject them into -Sdeps, otherwise they are only
162+
;; picked up with the next reload
163+
(update :extra-deps merge (:deps deps-local))
161164
;; It seems like if we set `{:aliases {}}` via `-Sdeps` it overrides
162165
;; deps.edn aliases, rather than merging them, so we merge them
163166
;; ourselves and pass them all to -Sdeps. Needs more testing to see if
@@ -217,7 +220,8 @@
217220
(-> ctx
218221
(update :requires conj 'lambdaisland.launchpad.watcher)
219222
(update :eval-forms (fnil conj [])
220-
`(lambdaisland.launchpad.watcher/watch! ~watch-handlers)))))
223+
`(future
224+
(lambdaisland.launchpad.watcher/watch! ~watch-handlers))))))
221225

222226
(defn clojure-cli-args [{:keys [aliases requires nrepl-port java-args middleware extra-deps alias-defs eval-forms] :as ctx}]
223227
(cond-> ["clojure"]
@@ -238,7 +242,10 @@
238242
(cond-> ctx
239243
(:go options)
240244
(update :eval-forms (fnil conj [])
241-
'(user/go))))
245+
'(try
246+
(user/go)
247+
(catch Exception e
248+
(println "(user/go) failed" e))))))
242249

243250
(defn run-nrepl-server [{:keys [nrepl-port middleware] :as ctx}]
244251
(-> ctx
@@ -258,6 +265,8 @@
258265
(as-> ctx <>
259266
(update <> :extra-deps assoc 'com.lambdaisland/classpath classpath-coords)
260267
(update <> :requires conj 'lambdaisland.launchpad.deps)
268+
(update <> :eval-forms (fnil conj [])
269+
`(lambdaisland.launchpad.deps/write-cpcache-file))
261270
(register-watch-handlers
262271
<>
263272
`(lambdaisland.launchpad.deps/watch-handlers

src/lambdaisland/launchpad/deps.clj

+22-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
[clojure.edn :as edn]
44
[clojure.java.io :as io]
55
[clojure.tools.deps.alpha :as deps]
6-
[lambdaisland.classpath.watch-deps :as watch-deps]))
6+
[clojure.string :as str]
7+
[lambdaisland.classpath.watch-deps :as watch-deps]
8+
[lambdaisland.classpath :as licp]))
79

810
(defn basis [opts]
911
(let [deps-local-file (io/file "deps.local.edn")
@@ -14,6 +16,22 @@
1416
(update :aliases concat (:launchpad/aliases deps-local))
1517
(assoc :extra extra-deps)))))
1618

19+
(defn write-cpcache-file
20+
"Write the current classpath to well-known location. Can be used to configure
21+
things like LSP that try to guess the classpath without having a running
22+
process.
23+
24+
e.g. .lsp/config.edn
25+
```
26+
{:project-specs [:classpath-cmd [\"cat\" \".cpcache/launchpad.edn\"]]}
27+
```
28+
"
29+
[]
30+
(spit ".cpcache/launchpad.cp"
31+
(str/join
32+
":"
33+
(time (mapcat second (licp/classpath-chain))))))
34+
1735
(defn watch-handlers [opts]
1836
(let [basis (basis opts)
1937
deps-paths (cond-> [(watch-deps/path watch-deps/process-root-path "deps.edn")
@@ -27,7 +45,9 @@
2745
(conj (watch-deps/canonical-path (:extra opts)))
2846
:always
2947
(concat (:watch-paths opts)))
30-
handler (partial #'watch-deps/on-event deps-paths opts)]
48+
handler (fn [e]
49+
(#'watch-deps/on-event deps-paths opts e)
50+
(write-cpcache-file))]
3151
(into {}
3252
(map (fn [p]
3353
[(str p) handler]))

src/lambdaisland/launchpad/shadow.clj

+1-2
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,4 @@
106106
(recur))))))
107107

108108
#_(start-builds :main)
109-
110-
(require 'shadow.build)
109+
#_(require 'shadow.build)

0 commit comments

Comments
 (0)