Skip to content

Commit

Permalink
fix more linting issues, and missing lodash dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
asoee committed Dec 10, 2024
1 parent 8d35372 commit 5a8e4a3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 42 deletions.
4 changes: 3 additions & 1 deletion packages/cursorless-jetbrains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
"@cursorless/common": "workspace:*",
"@cursorless/cursorless-engine": "workspace:*",
"@cursorless/test-case-recorder": "workspace:*",
"lodash-es": "^4.17.21",
"vscode-uri": "^3.0.8",
"web-tree-sitter": "0.24.4"
},
"devDependencies": {
"@types/chai": "^5.0.0"
"@types/chai": "^5.0.0",
"@types/lodash-es": "4.17.12"
}
}
42 changes: 2 additions & 40 deletions packages/cursorless-jetbrains/src/ide/JetbrainsConfiguration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { get } from "lodash";
import type {
Configuration,
ConfigurationScope,
Expand All @@ -7,6 +6,7 @@ import type {
import { CONFIGURATION_DEFAULTS } from "@cursorless/common";
import type { GetFieldType, Paths } from "@cursorless/common";
import { Notifier } from "@cursorless/common";
import { get } from "lodash-es";

export class JetbrainsConfiguration implements Configuration {
private notifier = new Notifier();
Expand All @@ -18,7 +18,7 @@ export class JetbrainsConfiguration implements Configuration {

getOwnConfiguration<Path extends Paths<CursorlessConfiguration>>(
path: Path,
scope?: ConfigurationScope,
_scope?: ConfigurationScope,
): GetFieldType<CursorlessConfiguration, Path> {
return get(this.configuration, path) as GetFieldType<
CursorlessConfiguration,
Expand All @@ -33,41 +33,3 @@ export class JetbrainsConfiguration implements Configuration {
this.notifier.notifyListeners();
}
}

export function createJetbrainsConfiguration(
configuration: CursorlessConfiguration,
): JetbrainsConfiguration {
return new JetbrainsConfiguration(configuration);
}

/**
* Gets a configuration value from jetbrains, with supported variables expanded.
* For example, `${userHome}` will be expanded to the user's home directory.
*
* We currently only support `${userHome}`.
*
* @param path The path to the configuration value, eg `cursorless.snippetsDir`
* @returns The configuration value, with variables expanded, or undefined if
* the value is not set
*/
export function jetbrainsGetConfigurationString(
path: string,
): string | undefined {
const index = path.lastIndexOf(".");
const section = path.substring(0, index);
const field = path.substring(index + 1);
// const value = "jetbrains.workspace.getConfiguration(section).get<string>(field)";
// return value != null ? evaluateStringVariables(value) : undefined;
return undefined;
}

function evaluateStringVariables(value: string): string {
return value.replace(/\${(\w+)}/g, (match, variable) => {
switch (variable) {
case "userHome":
return "~/";
default:
throw Error(`Unknown jetbrains configuration variable '${variable}'`);
}
});
}
2 changes: 1 addition & 1 deletion packages/cursorless-jetbrains/src/ide/JetbrainsIDE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
TextEditor,
WorkspaceFolder,
} from "@cursorless/common";
import { pull } from "lodash";
import { pull } from "lodash-es";
import { JetbrainsCapabilities } from "./JetbrainsCapabilities";
import { fromJetbrainsContentChange } from "./JetbrainsEvents";

Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a8e4a3

Please sign in to comment.