UNPKG

monaco-yaml

Version:

YAML plugin for the Monaco Editor

271 lines 7.7 kB
import type { IDisposable, MonacoEditor } from 'monaco-types'; import type { CompletionItemKind } from 'vscode-languageserver-types'; export interface JSONSchema { id?: string; $id?: string; $schema?: string; url?: string; type?: string | string[]; title?: string; closestTitle?: string; versions?: Record<string, string>; default?: unknown; definitions?: Record<string, JSONSchema>; description?: string; properties?: Record<string, boolean | JSONSchema>; patternProperties?: Record<string, boolean | JSONSchema>; additionalProperties?: boolean | JSONSchema; minProperties?: number; maxProperties?: number; dependencies?: Record<string, boolean | JSONSchema | string[]>; items?: (boolean | JSONSchema)[] | boolean | JSONSchema; minItems?: number; maxItems?: number; uniqueItems?: boolean; additionalItems?: boolean | JSONSchema; pattern?: string; minLength?: number; maxLength?: number; minimum?: number; maximum?: number; exclusiveMinimum?: boolean | number; exclusiveMaximum?: boolean | number; multipleOf?: number; required?: string[]; $ref?: string; anyOf?: (boolean | JSONSchema)[]; allOf?: (boolean | JSONSchema)[]; oneOf?: (boolean | JSONSchema)[]; not?: boolean | JSONSchema; enum?: unknown[]; format?: string; const?: unknown; contains?: boolean | JSONSchema; propertyNames?: boolean | JSONSchema; examples?: unknown[]; $comment?: string; if?: boolean | JSONSchema; then?: boolean | JSONSchema; else?: boolean | JSONSchema; defaultSnippets?: { label?: string; description?: string; markdownDescription?: string; type?: string; suggestionKind?: CompletionItemKind; sortText?: string; body?: unknown; bodyText?: string; }[]; errorMessage?: string; patternErrorMessage?: string; deprecationMessage?: string; enumDescriptions?: string[]; markdownEnumDescriptions?: string[]; markdownDescription?: string; doNotSuggest?: boolean; allowComments?: boolean; schemaSequence?: JSONSchema[]; filePatternAssociation?: string; } export interface SchemasSettings { /** * A `Uri` file match which will trigger the schema validation. This may be a glob or an exact * path. * * @example '.gitlab-ci.yml' * @example 'file://**\/.github/actions/*.yaml' */ fileMatch: string[]; /** * The JSON schema which will be used for validation. If not specified, it will be downloaded from * `uri`. */ schema?: JSONSchema; /** * The source URI of the JSON schema. The JSON schema will be downloaded from here if no schema * was supplied. It will also be displayed as the source in hover tooltips. */ uri: string; } export interface FormatterOptions { /** * Print spaces between brackets in objects. * * @default true */ readonly bracketSpacing?: boolean; /** * Enable/disable default YAML formatter. * * @default true */ readonly enable?: boolean; /** * Specify the line length that the printer will wrap on. * * @default 80 */ readonly printWidth?: number; /** * - `always`: wrap prose if it exceeds the print width. * - `never`: never wrap the prose, * - `preserve`: wrap prose as-is. * * @default `'preserve'` */ readonly proseWrap?: 'always' | 'never' | 'preserve'; /** * @default false */ readonly singleQuote?: boolean; /** * Specify if trailing commas should be used in JSON-like segments of the YAML. * * @default true */ readonly trailingComma?: boolean; } export interface MonacoYamlOptions { /** * If set, enable code lens. * * @default false */ readonly codeLens?: boolean; /** * If set, enable schema based autocompletion. * * @default true */ readonly completion?: boolean; /** * A list of custom tags. * * @default [] */ readonly customTags?: string[]; /** * Globally set `additionalProperties` to false if `additionalProperties` is not set and if * `schema.type` is `object`. So if is true, no extra properties are allowed inside yaml. * * @default false */ readonly disableAdditionalProperties?: boolean; /** * Disable adding not required properties with default values into completion text. * * @default false */ readonly disableDefaultProperties?: boolean; /** * If set, the schema service will load schema content on-demand. * * @default false */ readonly enableSchemaRequest?: boolean; /** * Control the use of flow mappings. * * @default 'allow' */ readonly flowMapping?: 'allow' | 'forbid'; /** * Control the use of flow sequences. * * @default 'allow' */ readonly flowSequence?: 'allow' | 'forbid'; /** * Formatting options. */ readonly format?: FormatterOptions; /** * If set, enable hover tips based the JSON schema. * * @default true */ readonly hover?: boolean; /** * Enable/disable hover feature for anchors * * @default true */ readonly hoverAnchor?: boolean; /** * Enable/disable showing the schema source in hover tooltips. * * @default true */ readonly hoverSchemaSource?: boolean; /** * Default indentation size * * @default ' ' */ readonly indentation?: string; /** * If true, a different diffing algorithm is used to generate error messages. * * @default false */ readonly isKubernetes?: boolean; /** * If set enforce alphabetical ordering of keys in mappings. * * @default false */ readonly keyOrdering?: boolean; /** * If true, the user must select some parent skeleton first before autocompletion starts to * suggest the rest of the properties. When yaml object is not empty, autocompletion ignores * this setting and returns all properties and skeletons. * * @default false */ readonly parentSkeletonSelectedFirst?: boolean; /** * A list of known schemas and/or associations of schemas to file names. * * @default [] */ readonly schemas?: SchemasSettings[]; /** * If set, the validator will be enabled and perform syntax validation as well as schema * based validation. * * @default true */ readonly validate?: boolean; /** * Default yaml lang version. * * @default '1.2' */ readonly yamlVersion?: '1.1' | '1.2'; } export interface MonacoYaml extends IDisposable { /** * Recondigure `monaco-yaml`. */ update: (options: MonacoYamlOptions) => Promise<undefined>; /** * Get the current configuration of `monaco-yaml`. */ getOptions: () => MonacoYamlOptions; } /** * Configure `monaco-yaml`. * * > **Note**: There may only be one configured instance of `monaco-yaml` at a time. * * @param monaco * The Monaco editor module. Typically you get this by importing `monaco-editor`. Third party * integrations often expose it as the global `monaco` variable instead. * @param options * Options to configure `monaco-yaml` * @returns * A disposable object that can be used to update `monaco-yaml` */ export declare function configureMonacoYaml(monaco: MonacoEditor, options?: MonacoYamlOptions): MonacoYaml; //# sourceMappingURL=index.d.ts.map