From c1f57f0a24506fdadce7bf5b2153d36ead3d3417 Mon Sep 17 00:00:00 2001 From: Chris Badahdah Date: Wed, 25 Sep 2024 19:07:00 -0700 Subject: [PATCH] Add `extraNReplMiddleware` to `connectSequence` Fixes #1691 --- CHANGELOG.md | 2 ++ docs/site/connect-sequences.md | 1 + src/nrepl/connectSequence.ts | 1 + src/nrepl/project-types.ts | 6 +++++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d989c3993..e1e4234b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Changes to Calva. ## [Unreleased] +- [Add `extraNReplMiddleware` to `connectSequence`](https://github.com/BetterThanTomorrow/calva/issues/1691) + ## [2.0.477] - 2024-09-29 - Fix: [Global custom repl command keys override workspace dittos, should be the other way around](https://github.com/BetterThanTomorrow/calva/issues/2640) diff --git a/docs/site/connect-sequences.md b/docs/site/connect-sequences.md index ea71a3212..454e4cb42 100644 --- a/docs/site/connect-sequences.md +++ b/docs/site/connect-sequences.md @@ -44,6 +44,7 @@ A connect sequence configures the following: * `cljsLaunchBuilds`: The cljs builds to start/watch at Jack-in/connect. * `cljsDefaultBuild`: Which cljs build to attach to at the initial connect. * `jackInEnv`: An object with environment variables that will be merged with the global `calva.jackInEnv` and then applied to the Jack-in process. The merge is very similar to how Clojure's `merge` works. So for any common keys between the global setting and this one, the ones from this setting will win. +* `extraNReplMiddleware`: Array of strings of the fully qualified names of extra middleware that should be applied to the nREPL server when started. The [Calva built-in sequences](https://github.com/BetterThanTomorrow/calva/blob/published/src/nrepl/connectSequence.ts) also use this format, check them out to get a clearer picture of how these settings work. diff --git a/src/nrepl/connectSequence.ts b/src/nrepl/connectSequence.ts index 169339717..0be0bccca 100644 --- a/src/nrepl/connectSequence.ts +++ b/src/nrepl/connectSequence.ts @@ -67,6 +67,7 @@ interface ReplConnectSequence { cljsType: CljsTypes | CljsTypeConfig; menuSelections?: MenuSelections; nReplPortFile?: string[]; + extraNReplMiddleware?: string[]; jackInEnv?: Record; } diff --git a/src/nrepl/project-types.ts b/src/nrepl/project-types.ts index ba5c142e7..835ae322d 100644 --- a/src/nrepl/project-types.ts +++ b/src/nrepl/project-types.ts @@ -668,7 +668,11 @@ async function cljCommandLine(connectSequence: ReplConnectSequence, cljsType: Cl ...(cljsType ? { ...cljsDependencies()[cljsType] } : {}), ...serverPrinterDependencies, }; - const useMiddleware = [...middleware, ...(cljsType ? cljsMiddleware[cljsType] : [])]; + const useMiddleware = [ + ...middleware, + ...(cljsType ? cljsMiddleware[cljsType] : []), + ...(connectSequence.extraNReplMiddleware || []), + ]; const aliasesFlag = getStateValue('isClojureCLIVersionAncient') ? ['-A', ''] : ['-M', '-M']; const aliasesOption =