From 2554ccb312912c2d89adb1198a4be46415a25afa Mon Sep 17 00:00:00 2001 From: Fran Zekan Date: Thu, 12 Oct 2023 21:14:05 +0200 Subject: [PATCH] feat(intelij based editors): Reuse idea spec for other intelij based editors (#2109) --- src/clion.ts | 4 + src/goland.ts | 4 + src/idea.ts | 316 ++++++++++++++++++++++++----------------------- src/phpstorm.ts | 4 + src/pycharm.ts | 4 + src/rubymine.ts | 4 + src/rustrover.ts | 4 + src/webstorm.ts | 4 + 8 files changed, 190 insertions(+), 154 deletions(-) create mode 100644 src/clion.ts create mode 100644 src/goland.ts create mode 100644 src/phpstorm.ts create mode 100644 src/pycharm.ts create mode 100644 src/rubymine.ts create mode 100644 src/rustrover.ts create mode 100644 src/webstorm.ts diff --git a/src/clion.ts b/src/clion.ts new file mode 100644 index 000000000000..928cce7fe457 --- /dev/null +++ b/src/clion.ts @@ -0,0 +1,4 @@ +import { generateInteliJCompletionSpec } from "./idea"; + +const completionSpec = generateInteliJCompletionSpec("clion", "CLion"); +export default completionSpec; diff --git a/src/goland.ts b/src/goland.ts new file mode 100644 index 000000000000..da8c0e2e1d9f --- /dev/null +++ b/src/goland.ts @@ -0,0 +1,4 @@ +import { generateInteliJCompletionSpec } from "./idea"; + +const completionSpec = generateInteliJCompletionSpec("goland", "GoLand"); +export default completionSpec; diff --git a/src/idea.ts b/src/idea.ts index 36f5191cb9c1..4fc7ac604790 100644 --- a/src/idea.ts +++ b/src/idea.ts @@ -1,160 +1,168 @@ -const completionSpec: Fig.Spec = { - name: "idea", - description: "IntelliJ IDEA cli", - subcommands: [ - { - name: "", - description: "Without any arguments, the script launches IntelliJ IDEA", +export const generateInteliJCompletionSpec = ( + name: string, + editorName: string +): Fig.Spec => { + return { + name, + description: `${editorName} cli`, + args: { + name: "path", + template: "filepaths", }, - { - name: "diff", - description: - "Open the diff viewer to see the differences between two specified files", - args: [ - { - name: "path", - template: "filepaths", - }, - { - name: "path2", - template: "filepaths", - }, - { - name: "path3-optional", - template: "filepaths", - }, - ], - }, - { - name: "merge", - description: "Open the Merge dialog to merge the specified files", - args: [ - { - name: "path", - template: "filepaths", - }, - { - name: "path2", - template: "filepaths", - }, - { - name: "base-optional", - template: "filepaths", - }, - ], - }, - { - name: "format", - description: "Apply code style formatting to the specified files", - args: { - name: "path...", - template: "filepaths", + subcommands: [ + { + name: "diff", + description: + "Open the diff viewer to see the differences between two specified files", + args: [ + { + name: "path", + template: "filepaths", + }, + { + name: "path2", + template: "filepaths", + }, + { + name: "path3-optional", + template: "filepaths", + }, + ], }, - options: [ - { - name: "-h", - description: "Show help for format command", - }, - { - name: ["-m", "-mask"], - description: - "Specify a comma-separated list of file masks that define the files to be processed", - }, - { - name: ["-r", "-R"], - description: "Process specified directories recursively", - }, - { - name: ["-s", "-settings"], - description: - "Specify the code style settings file to use for formatting", - }, - { - name: "-allowDefaults", - description: - "Use the default code style settings when the code style is not defined for a file or a group of files", - }, - { - name: "-charset", - description: - "Preserve encoding and enforce the charset for reading and writing source files", - }, - { - name: ["-d", "-dry"], - description: "Run the formatter in the validation mode", - }, - ], - }, - { - name: "inspect", - description: "Perform code inspection on the specified project", - args: [ - { - name: "project", - template: "folders", - }, - { - name: "inspection-profile", - template: "filepaths", - }, - { - name: "output", + { + name: "merge", + description: "Open the Merge dialog to merge the specified files", + args: [ + { + name: "path", + template: "filepaths", + }, + { + name: "path2", + template: "filepaths", + }, + { + name: "base-optional", + template: "filepaths", + }, + ], + }, + { + name: "format", + description: "Apply code style formatting to the specified files", + args: { + name: "path...", template: "filepaths", }, - ], - options: [ - { - name: "-changes", - description: "Run inspections only on local uncommitted changes", - }, - { - name: "-d", - description: - "Specify the full path to the subdirectory if you don't want to inspect the whole project", - }, - { - name: "-format", - description: - "Specify the format of the output file with inspection results", - }, - { - name: "-v", - description: "Set the verbosity level of the output", - }, - ], - }, - { - name: "installPlugins", - description: - "Install plugins by plugin ID from JetBrains Marketplace or a custom plugin repository", - args: [ - { - name: "plugin-id", - }, - { - name: "repository-url ", - }, - ], - }, - ], - options: [ - { - name: "nosplash", - description: "Do not show the splash screen when loading IntelliJ IDEA", - }, - { - name: "dontReopenProjects", - description: "Do not reopen projects and show the welcome screen", - }, - { - name: "disableNonBundledPlugins", - description: "Do not load manually installed plugins", - }, - { - name: "--wait", - description: - "Wait for the files to be closed before returning to the command prompt", - }, - ], + options: [ + { + name: "-h", + description: "Show help for format command", + }, + { + name: ["-m", "-mask"], + description: + "Specify a comma-separated list of file masks that define the files to be processed", + }, + { + name: ["-r", "-R"], + description: "Process specified directories recursively", + }, + { + name: ["-s", "-settings"], + description: + "Specify the code style settings file to use for formatting", + }, + { + name: "-allowDefaults", + description: + "Use the default code style settings when the code style is not defined for a file or a group of files", + }, + { + name: "-charset", + description: + "Preserve encoding and enforce the charset for reading and writing source files", + }, + { + name: ["-d", "-dry"], + description: "Run the formatter in the validation mode", + }, + ], + }, + { + name: "inspect", + description: "Perform code inspection on the specified project", + args: [ + { + name: "project", + template: "folders", + }, + { + name: "inspection-profile", + template: "filepaths", + }, + { + name: "output", + template: "filepaths", + }, + ], + options: [ + { + name: "-changes", + description: "Run inspections only on local uncommitted changes", + }, + { + name: "-d", + description: + "Specify the full path to the subdirectory if you don't want to inspect the whole project", + }, + { + name: "-format", + description: + "Specify the format of the output file with inspection results", + }, + { + name: "-v", + description: "Set the verbosity level of the output", + }, + ], + }, + { + name: "installPlugins", + description: + "Install plugins by plugin ID from JetBrains Marketplace or a custom plugin repository", + args: [ + { + name: "plugin-id", + }, + { + name: "repository-url ", + }, + ], + }, + ], + options: [ + { + name: "nosplash", + description: `Do not show the splash screen when loading ${editorName}`, + }, + { + name: "dontReopenProjects", + description: "Do not reopen projects and show the welcome screen", + }, + { + name: "disableNonBundledPlugins", + description: "Do not load manually installed plugins", + }, + { + name: "--wait", + description: + "Wait for the files to be closed before returning to the command prompt", + }, + ], + }; }; + +const completionSpec = generateInteliJCompletionSpec("idea", "InteliJ IDEA"); + export default completionSpec; diff --git a/src/phpstorm.ts b/src/phpstorm.ts new file mode 100644 index 000000000000..ab234e2cfe6c --- /dev/null +++ b/src/phpstorm.ts @@ -0,0 +1,4 @@ +import { generateInteliJCompletionSpec } from "./idea"; + +const completionSpec = generateInteliJCompletionSpec("phpstorm", "PhpStorm"); +export default completionSpec; diff --git a/src/pycharm.ts b/src/pycharm.ts new file mode 100644 index 000000000000..2b39e1ed515d --- /dev/null +++ b/src/pycharm.ts @@ -0,0 +1,4 @@ +import { generateInteliJCompletionSpec } from "./idea"; + +const completionSpec = generateInteliJCompletionSpec("pycharm", "PyCharm"); +export default completionSpec; diff --git a/src/rubymine.ts b/src/rubymine.ts new file mode 100644 index 000000000000..6dd98e451b8e --- /dev/null +++ b/src/rubymine.ts @@ -0,0 +1,4 @@ +import { generateInteliJCompletionSpec } from "./idea"; + +const completionSpec = generateInteliJCompletionSpec("rubymine", "RubyMine"); +export default completionSpec; diff --git a/src/rustrover.ts b/src/rustrover.ts new file mode 100644 index 000000000000..8f2756368255 --- /dev/null +++ b/src/rustrover.ts @@ -0,0 +1,4 @@ +import { generateInteliJCompletionSpec } from "./idea"; + +const completionSpec = generateInteliJCompletionSpec("rustrover", "RustRover"); +export default completionSpec; diff --git a/src/webstorm.ts b/src/webstorm.ts new file mode 100644 index 000000000000..b630296a2ac9 --- /dev/null +++ b/src/webstorm.ts @@ -0,0 +1,4 @@ +import { generateInteliJCompletionSpec } from "./idea"; + +const completionSpec = generateInteliJCompletionSpec("webstorm", "WebStorm"); +export default completionSpec;