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

Support Hack root in an arbitrary subdirectory #95

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
"default": "hh_client",
"description": "Absolute path to the hh_client executable. This can be left empty if hh_client is already in your environment $PATH."
},
"hack.hhconfigPath": {
"type": "string",
"default": ".hhconfig",
"description": "Workspace-relative path to .hhconfig file, the containing directory becomes the Hack Langauge Server root"
},
"hack.workspaceRootPath": {
"type": "string",
"default": null,
Expand Down Expand Up @@ -311,7 +316,7 @@
]
},
"activationEvents": [
"workspaceContains:.hhconfig",
"workspaceContains:**/.hhconfig",
"onDebug"
],
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const hackConfig = vscode.workspace.getConfiguration("hack");
// tslint:disable-next-line:no-non-null-assertion
export const localWorkspacePath = vscode.workspace.workspaceFolders![0].uri
.fsPath;
export const hhconfigPath = hackConfig.get<string>("hhconfigPath") || ".hhconfig";

export let clientPath = hackConfig.get<string>("clientPath") || "hh_client";
clientPath = clientPath.replace("${workspaceFolder}", localWorkspacePath);
Expand Down
10 changes: 5 additions & 5 deletions src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import * as config from "./Config";
* @param includeScheme Whether to include the file:// scheme in the response or not
*/
export const mapFromWorkspaceUri = (file: vscode.Uri): string => {
if (!config.remoteEnabled || !config.remoteWorkspacePath) {
return file.toString();
let workspaceRoot = file.toString()
if (config.remoteEnabled && config.remoteWorkspacePath) {
workspaceRoot = workspaceRoot.replace(config.localWorkspacePath, config.remoteWorkspacePath);
}
return file
.toString()
.replace(config.localWorkspacePath, config.remoteWorkspacePath);
const workspaceRelativeRoot = config.hhconfigPath.replace(/\.hhconfig$/, "")
return workspaceRoot + "/" + workspaceRelativeRoot.replace(".hhconfig", "");
};

/**
Expand Down