Skip to content

Commit

Permalink
Merge pull request #2636 from djblue/nrepl-middleware
Browse files Browse the repository at this point in the history
Add `extrNReplMiddleware` to `connectSequence`

* Fixes #1691
  • Loading branch information
PEZ authored Sep 30, 2024
2 parents 2e84239 + c1f57f0 commit ae3905a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/site/connect-sequences.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions src/nrepl/connectSequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ interface ReplConnectSequence {
cljsType: CljsTypes | CljsTypeConfig;
menuSelections?: MenuSelections;
nReplPortFile?: string[];
extraNReplMiddleware?: string[];
jackInEnv?: Record<string, string>;
}

Expand Down
6 changes: 5 additions & 1 deletion src/nrepl/project-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit ae3905a

Please sign in to comment.