Skip to content

Commit

Permalink
Move rootProjectDir to root of replConnectSequences
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-toubia committed Mar 9, 2020
1 parent 3a3367e commit 2218810
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/readthedocs/source/connect-sequences.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ A connect sequence configures the following:
* `projectType`: (required) This is either "Leiningen”, ”Clojure-CLI”, or ”shadow-cljs”.
* `nReplPortFile`: An array of path segments with the project root-relative path to the nREPL port file for this connect sequence. E.g. For shadow-cljs this would be `[".shadow-cljs", "nrepl.port"]`.
* `afterCLJReplJackInCode`: Here you can give Calva some Clojure code to evaluate in the CLJ REPL, once it has been created.
* `projectRootDir`: The root directory to execute the Jack-in command from. This will override the default behavior for determining the root directory relative to the current open file. This is useful for working in monorepos.
* `cljsType`: This can be either "Figwheel Main", "lein-figwheel", "shadow-cljs", "Nashorn", or a dictionary configuring a custom type. If omitted, Calva will skip connecting a ClojureScript repl. A custom type has the following fields:
* `dependsOn`: (required) Calva will use this to determine which dependencies it will add when starting the project (Jacking in). This can be either "Figwheel Main", "lein-figwheel", "shadow-cljs", "Nashorn", or ”User provided”. If it is "User provided", then you need to provide the dependencies in the project, or launch with an alias (deps.edn), profile (Leiningen), or build (shadow-cljs) that provides the dependencies needed.
* `isStarted`: Boolean. For CLJS REPLs that Calva does not need to start, set this to true. (If you base your custom cljs repl on a shadow-cljs workflow, for instance.)
Expand All @@ -33,7 +34,6 @@ A connect sequence configures the following:
* `cljAliases`: At Jack-in to a Clojure CLI project, use these aliases to launch the repl.
* `cljsLaunchBuilds`: The cljs builds to start/watch at Jack-in/connect.
* `cljsDefaultBuild`: Which cljs build to attach to at the initial connect.
* `projectRootDir`: The root directory to execute the Jack-in command from. This will override the default behavior for determining the root directory relative to the current open file. This is useful for working in monorepos.

The [Calva built-in sequences](https://github.com/BetterThanTomorrow/calva/blob/master/calva/nrepl/connectSequence.ts) also uses this format, check them out to get a clearer picture of how these settings work.

Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@
"description": "Here you can give Calva some Clojure code to evaluate in the CLJ REPL, once it has been created.",
"required": false
},
"projectRootDir": {
"type": "string",
"descripion": "Defines the project root directory. Useful for working with monorepos.",
"required": false
},
"menuSelections": {
"type": "object",
"description": "Pre-selected menu options. If a slection is made here. Calva won't prompt for it.",
Expand Down Expand Up @@ -414,10 +419,6 @@
"cljsDefaultBuild": {
"type": "string",
"description": "Which cljs build to attach to at the initial connect."
},
"projectRootDir": {
"type": "string",
"descripion": "Defines the project root directory. Useful for working with monorepos."
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/nrepl/connectSequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ interface MenuSelections {
cljAliases?: string[],
cljsLaunchBuilds?: string[],
cljsDefaultBuild?: string,
projectRootDir?: string,
}

interface ReplConnectSequence {
name: string,
projectType: ProjectTypes,
afterCLJReplJackInCode?: string,
projectRootDir?: string,
cljsType: CljsTypes | CljsTypeConfig,
menuSelections?: MenuSelections,
nReplPortFile?: string[]
Expand Down
2 changes: 1 addition & 1 deletion src/nrepl/jack-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function cancelJackInTask() {

async function executeJackInTask(projectType: projectTypes.ProjectType, projectTypeSelection: any, executable: string, args: any, cljTypes: string[], outputChannel: vscode.OutputChannel, connectSequence: ReplConnectSequence) {
// If the connection sequence specifies a project root dir, override the existing project dir
const projectRootDir = connectSequence?.menuSelections?.projectRootDir;
const projectRootDir = connectSequence?.projectRootDir;
if(projectRootDir) state.setProjectRoot(projectRootDir);

utilities.setLaunchingState(projectTypeSelection);
Expand Down
1 change: 1 addition & 0 deletions src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export function getProjectWsFolder(): vscode.WorkspaceFolder {
* by looking for project files from the file's directory and up to
* the window root (for plain folder windows) or the file's
* workspace folder root (for workspaces) to find the project root.
*
* If there is no project file found, throw an exception.
*/
export async function initProjectDir(): Promise<void> {
Expand Down

0 comments on commit 2218810

Please sign in to comment.