Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add projectRootDir setting #580

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changes to Calva.
## [Unreleased]

## [2.0.80] - 2020-03-07
- Add replConnectSequences.menuSelections.projectRootDir for manually specifying the root directory in order to support jack-in for monorepo projects.
stefan-toubia marked this conversation as resolved.
Show resolved Hide resolved
- Fix so that Paredit treats symbols containing the quote character correctly.
- [Fix: Parameter hints popup should be off by default](https://github.com/BetterThanTomorrow/calva/issues/574)
- [Fix: `nil` followed by comma not highlighted correctly](https://github.com/BetterThanTomorrow/calva/issues/577)
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."
stefan-toubia marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
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);
PEZ marked this conversation as resolved.
Show resolved Hide resolved

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) {
PEZ marked this conversation as resolved.
Show resolved Hide resolved
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