From 30cc9108e2e669699e4a260eae6252ee5d51f9a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 24 Sep 2024 21:49:44 +0200 Subject: [PATCH 1/3] Avoid tripping up tools.reader on backticked forms Similar to have we handle `#_`, we replace backtick with single quote. * Fixes #2633 --- src/cljs-lib/src/calva/parse.cljs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cljs-lib/src/calva/parse.cljs b/src/cljs-lib/src/calva/parse.cljs index 8ec0792bc..7a33eeabb 100644 --- a/src/cljs-lib/src/calva/parse.cljs +++ b/src/cljs-lib/src/calva/parse.cljs @@ -23,7 +23,11 @@ "Parses out all top level forms from `s`. Returns a vector with the parsed forms." [s] - (let [pbr (rt/string-push-back-reader (str/replace s #"#=\(" "nil #_("))] + (let [pbr (rt/string-push-back-reader (-> s ; tools.reader croaks on some Clojure constructs + ; at least the way we use it here + ; And we're not interested in actually parsing these + (str/replace #"#=\(" "nil #_(") + (str/replace #"`" "'")))] (loop [parsed-forms []] (let [parsed-form (tr/read {:eof 'CALVA-EOF :read-cond :preserve} pbr)] From 4b1f8101308eb0542e5e851897c4c20a5fe3b33f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 24 Sep 2024 21:58:15 +0200 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 372572aed..c8302caf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,12 @@ Changes to Calva. ## [Unreleased] +- Fix: [Can't start REPL in lein projects with backtick on project.clj](https://github.com/BetterThanTomorrow/calva/issues/2633) + ## [2.0.474] - 2024-09-22 - [Synchronize the file extensions for Calva and Calva Spritz](https://github.com/BetterThanTomorrow/calva/issues/2629) -- [Terminal output pretty printing fails when using `printerFn` pretty print option](https://github.com/BetterThanTomorrow/calva/issues/2630) +- Fix: [Terminal output pretty printing fails when using `printerFn` pretty print option](https://github.com/BetterThanTomorrow/calva/issues/2630) ## [2.0.473] - 2024-09-21 From 528e7a604e670cfc8a4a648e8853f49432df9302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Tue, 24 Sep 2024 22:08:37 +0200 Subject: [PATCH 3/3] Inform about workaround when parsing project.clj file fails --- src/nrepl/project-types.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nrepl/project-types.ts b/src/nrepl/project-types.ts index 379be0c2f..ba5c142e7 100644 --- a/src/nrepl/project-types.ts +++ b/src/nrepl/project-types.ts @@ -158,7 +158,9 @@ async function leinDefProject(): Promise { const parsed = parseForms(data); return parsed.find((x) => x[0] == 'defproject'); } catch (e) { - void vscode.window.showErrorMessage('Could not parse project.clj'); + void vscode.window.showErrorMessage( + "Could not parse project.clj. You'll need to start the REPL manually, and then use the Connect REPL command instead." + ); throw e; } }