diff --git a/docs/readthedocs/source/connect-sequences.md b/docs/readthedocs/source/connect-sequences.md index 7943f328d..e02af2fe8 100644 --- a/docs/readthedocs/source/connect-sequences.md +++ b/docs/readthedocs/source/connect-sequences.md @@ -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.) @@ -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. diff --git a/package.json b/package.json index 2070ce2d0..ec955d924 100644 --- a/package.json +++ b/package.json @@ -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.", @@ -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." } } }, diff --git a/src/nrepl/connectSequence.ts b/src/nrepl/connectSequence.ts index 1b5b058ef..5bfa81643 100644 --- a/src/nrepl/connectSequence.ts +++ b/src/nrepl/connectSequence.ts @@ -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[] diff --git a/src/nrepl/jack-in.ts b/src/nrepl/jack-in.ts index 37019c95a..c740be710 100644 --- a/src/nrepl/jack-in.ts +++ b/src/nrepl/jack-in.ts @@ -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); diff --git a/src/state.ts b/src/state.ts index e4ef100e7..04d3af8bb 100644 --- a/src/state.ts +++ b/src/state.ts @@ -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 {