Skip to content

Commit

Permalink
Merge pull request withfig#211 from Tyriar/code-autocomplete
Browse files Browse the repository at this point in the history
[CODE] Fill out completion spec for code (VS Code)
  • Loading branch information
cstrnt authored May 23, 2021
2 parents 1e28d10 + c3e1353 commit 56fc02e
Show file tree
Hide file tree
Showing 13 changed files with 5,882 additions and 5,022 deletions.
276 changes: 245 additions & 31 deletions dev/code.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,254 @@
const commonOptions: Fig.Option[] = [
{
name: ["-d", "--diff"],
description: "Compare two files with each other.",
args: [
{
name: "file",
template: "filepaths",
},
{
name: "file",
template: "filepaths",
},
],
},
{
name: ["-a", "--add"],
description: "Add folder(s) to the last active window",
args: {
name: "folder",
template: "folders",
variadic: true,
},
},
{
name: ["-g", "--goto"],
description:
"Open a file at the path on the specified line and character position.",
args: {
name: "file:line[:character]",
// TODO: Support :line[:character] completion?
template: "filepaths",
},
},
{
name: ["-n", "--new-window"],
description: "Force to open a new window.",
},
{
name: ["-r", "--reuse-window"],
description: "Force to open a file or folder in an already opened window.",
},
{
name: ["-w", "--wait"],
description: "Wait for the files to be closed before returning.",
},
{
name: "--locale",
description: "The locale to use (e.g. en-US or zh-TW).",
args: {
name: "locale",
suggestions: [
// Supported locales: https://code.visualstudio.com/docs/getstarted/locales#_available-locales
{ name: "en", icon: "🇺🇸", description: "English (US)" },
{ name: "zh-CN", icon: "🇨🇳", description: "Simplified Chinese" },
{ name: "zh-TW", icon: "🇹🇼", description: "Traditional Chinese" },
{ name: "fr", icon: "🇫🇷", description: "French" },
{ name: "de", icon: "🇩🇪", description: "German" },
{ name: "it", icon: "🇮🇹", description: "Italian" },
{ name: "es", icon: "🇪🇸", description: "Spanish" },
{ name: "ja", icon: "🇯🇵", description: "Japanese" },
{ name: "ko", icon: "🇰🇷", description: "Korean" },
{ name: "ru", icon: "🇷🇺", description: "Russian" },
{ name: "bg", icon: "🇧🇬", description: "Bulgarian" },
{ name: "hu", icon: "🇭🇺", description: "Hungarian" },
{ name: "pt-br", icon: "🇧🇷", description: "Portuguese (Brazil)" },
{ name: "tr", icon: "🇹🇷", description: "Turkish" },
],
},
},
{
name: "--user-data-dir",
description:
"Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.",
args: {
name: "dir",
template: "folders",
},
},
{
name: ["-h", "--help"],
description: "Print usage.",
},
];

const extensionManagementOptions: Fig.Option[] = [
{
name: "--extensions-dir",
description: "Set the root path for extensions.",
args: {
name: "dir",
template: "folders",
},
},
{
name: "--list-extensions",
description: "List the installed extensions.",
},
{
name: "--category",
description:
"Filters installed extensions by provided category, when using --list-extensions.",
args: {
name: "category",
suggestions: [
"azure",
"data science",
"debuggers",
"extension packs",
"education",
"formatters",
"keymaps",
"language packs",
"linters",
"machine learning",
"notebooks",
"programming languages",
"scm providers",
"snippets",
"testing",
"themes",
"visualization",
"other",
],
},
},
{
name: "--show-versions",
description:
"Show versions of installed extensions, when using --list-extensions.",
},
{
name: "--install-extension",
description:
"Installs or updates the extension. The identifier of an extension is always `${publisher}.${name}\n\nUse `--force` argument to update to latest version. To install a specific version provide `@${version}`. For example: '[email protected]'.",
args: {
// TODO: Create extension ID generator
name: "extension-id[@version] | path-to-vsix",
},
},
{
name: "--uninstall-extension",
description: "Uninstalls an extension.",
args: {
// TODO: Create extension ID generator
name: "extension-id",
},
},
{
name: "--enable-proposed-api",
description:
"Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.",
},
];

const troubleshootingOptions: Fig.Option[] = [
{
name: ["-v", "--version"],
description: "Print version.",
},
{
name: "--verbose",
description: "Print verbose output (implies --wait).",
},
{
name: "--log",
description: "Log level to use. Default is 'info' when unspecified.",
args: {
name: "level",
suggestions: [
"critical",
"error",
"warn",
"info",
"debug",
"trace",
"off",
],
},
},
{
name: ["-s", "--status"],
description: "Print process usage and diagnostics information.",
},
{
name: "--prof-startup",
description: "Run CPU profiler during startup.",
},
{
name: "--disable-extensions",
description: "Disable all installed extensions.",
},
{
name: "--disable-extension",
description: "Disable an extension.",
args: {
// TODO: Create extension ID generator
name: "extension-id",
},
},
{
name: "--sync",
description: "Turn sync on or off.",
args: {
name: "Whether to enable sync",
suggestions: ["on", "off"],
},
},
{
name: "--inspect-extensions",
description:
"Allow debugging and profiling of extensions. Check the developer tools for the connection URI.",
args: {
name: "port",
},
},
{
name: "--inspect-brk-extensions",
description:
"Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.",
args: {
name: "port",
},
},
{
name: "--disable-gpu",
description: "Disable GPU hardware acceleration.",
},
{
name: "--max-memory",
description: "Max memory size for a window (in Mbytes).",
args: {
name: "memory",
description: "Memory in megabytes",
},
},
{
name: "--telemetry",
description: "Shows all telemetry events which VS code collects.",
},
];

export const completionSpec: Fig.Spec = {
name: "code",
description: "Visual Studio Code",
args: {
template: ["filepaths", "folders"],
},
options: [
{
name: ["-d", "--diff"],
description: "Compare two files with each other.",
args: [
{
template: "filepaths",
},
{
template: "filepaths",
},
],
},
{
name: ["-a", "--add"],
description: "Add folder(s) to the last active window",
args: {
template: "folders",
},
},
{
name: ["-n", "--new-window"],
description: "Force to open a new window.",
args: [
{
template: "filepaths",
},
{
template: "filepaths",
},
],
},
...commonOptions,
...extensionManagementOptions,
...troubleshootingOptions,
],
};
Loading

0 comments on commit 56fc02e

Please sign in to comment.