Skip to content

Commit

Permalink
Add projectRootDir setting
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-toubia committed Mar 7, 2020
1 parent 53397bc commit 8b4cfcf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Changes to Calva.

## [Unreleased]
- Add replConnectSequences.menuSelections.projectRootDir for manually specifying the root directory in order to support jack-in for monorepo projects.
- Fix so that Calva treats symbol containing the quote character correctly.
- [Fix: Parameter hints popup should be off by default](https://github.com/BetterThanTomorrow/calva/issues/574)

Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@
"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
5 changes: 3 additions & 2 deletions src/nrepl/connectSequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ interface MenuSelections {
leinAlias?: string,
cljAliases?: string[],
cljsLaunchBuilds?: string[],
cljsDefaultBuild?: string
cljsDefaultBuild?: string,
projectRootDir?: string,
}

interface ReplConnectSequence {
Expand Down Expand Up @@ -242,4 +243,4 @@ export {
CljsTypes,
ReplConnectSequence,
CljsTypeConfig
}
}
4 changes: 4 additions & 0 deletions src/nrepl/jack-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ 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;
if(projectRootDir) state.setProjectRoot(projectRootDir);

utilities.setLaunchingState(projectTypeSelection);
statusbar.update();
const nReplPortFile = projectTypes.nreplPortFile(connectSequence);
Expand Down
7 changes: 5 additions & 2 deletions src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ export function getProjectRoot(useCache = true): string {
}
}

export function setProjectRoot(rootPath: string) {
cursor.set(PROJECT_DIR_KEY, rootPath);
}

export function getProjectWsFolder(): vscode.WorkspaceFolder {
const doc = util.getDocument({});
return doc ? vscode.workspace.getWorkspaceFolder(doc.uri) : null;
Expand All @@ -173,7 +177,6 @@ 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 Expand Up @@ -223,7 +226,7 @@ export async function initProjectDir(): Promise<void> {
for (let projectFile in projectFileNames) {
const p = path.resolve(rootPath, projectFileNames[projectFile]);
if (fs.existsSync(p)) {
cursor.set(PROJECT_DIR_KEY, rootPath);
setProjectRoot(rootPath);
return;
}
}
Expand Down

0 comments on commit 8b4cfcf

Please sign in to comment.