ドキュメント

インテグレーション

config.ts ファイル

ベータ版機能

プラグインサポートは現在プライベートベータ版です。こちらからベータ版に参加してください。

デフォルトでは、プラグイン スキャフォールディングは、設定のスキーマを含む config.ts ファイルを src/ ディレクトリに作成します。ファイルが存在しない場合は、手動で作成できます。

import { createConfigSchematics } from "@lmstudio/sdk";

export const configSchematics = createConfigSchematics()
  .field(
    "myCustomField", // The key of the field.
    "numeric", // Type of the field.
    // Options for the field. Different field types will have different options.
    {
      displayName: "My Custom Field",
      hint: "This is my custom field. Doesn't do anything special.",
      slider: { min: 0, max: 100, step: 1 }, // Add a slider to the field.
    },
    80, // Default Value
  )
  // You can add more fields by chaining the field method.
  // For example:
  //   .field("anotherField", ...)
  .build();

export const globalConfigSchematics = createConfigSchematics()
  .field(
    "myGlobalCustomField", // The key of the field.
    "string",
    {
      displayName: "My Global Custom Field",
      hint: "This is my global custom field. Doesn't do anything special.",
    },
    "default value", // Default Value
  )
  // You can add more fields by chaining the field method.
  // For example:
  //  .field("anotherGlobalField", ...)
  .build();

設定スキーマを手動で追加した場合は、プラグインの index.ts ファイルにも設定を登録する必要があります。

これは、プラグインの main 関数で context.withConfigSchematics(configSchematics) および context.withGlobalConfigSchematics(globalConfigSchematics) を呼び出すことによって行われます。

// ... other imports ...
import { toolsProvider } from "./toolsProvider";

export async function main(context: PluginContext) {
  // ... other plugin setup code ...

  // Register the configuration schematics.
  context.withConfigSchematics(configSchematics);
  // Register the global configuration schematics.
  context.withGlobalConfigSchematics(globalConfigSchematics);

  // ... other plugin setup code ...
}

このページのソースは GitHub で利用可能です。