mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-06-20 23:11:05 +00:00
Update dependencies
- Both `js-yaml` and `yaml-languageserver-parser` have been replaced with `yaml`. - `jsonc-parser` has been externalized. - All defaults are now specified explicitly. - The new property `yamlVersion` has been added to match `yaml-language-server`. The default is `1.2`. - `DiagnosticsOptions` properties are now sorted alphabetically and documentation has been enhanced. Closes #117
This commit is contained in:
parent
4e30f4cf16
commit
554699887d
8 changed files with 3100 additions and 3258 deletions
2
build.js
2
build.js
|
|
@ -28,7 +28,7 @@ fs.rm(join(__dirname, 'lib'), { force: true, recursive: true })
|
|||
}));
|
||||
// The yaml language service only imports re-exports of vscode-languageserver-types from
|
||||
// vscode-languageserver.
|
||||
onResolve({ filter: /^vscode-languageserver$/ }, () => ({
|
||||
onResolve({ filter: /^vscode-languageserver(\/node)?$/ }, () => ({
|
||||
path: 'vscode-languageserver-types/lib/esm/main.js',
|
||||
external: true,
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
"css-minimizer-webpack-plugin": "^3.0.0",
|
||||
"html-webpack-plugin": "^5.0.0",
|
||||
"mini-css-extract-plugin": "^2.0.0",
|
||||
"monaco-editor": "^0.27.0",
|
||||
"monaco-editor": "^0.29.0",
|
||||
"monaco-yaml": "file:../..",
|
||||
"ts-loader": "^9.0.0",
|
||||
"typescript": "^4.0.0",
|
||||
|
|
|
|||
|
|
@ -44,11 +44,6 @@ const defaultSchema: SchemasSettings = {
|
|||
};
|
||||
|
||||
setDiagnosticsOptions({
|
||||
validate: true,
|
||||
enableSchemaRequest: true,
|
||||
format: true,
|
||||
hover: true,
|
||||
completion: true,
|
||||
schemas: [defaultSchema],
|
||||
});
|
||||
|
||||
|
|
|
|||
78
index.d.ts
vendored
78
index.d.ts
vendored
|
|
@ -29,44 +29,76 @@ declare module 'monaco-editor/esm/vs/editor/editor.api' {
|
|||
export interface DiagnosticsOptions {
|
||||
/**
|
||||
* If set, enable schema based autocompletion.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly completion?: boolean;
|
||||
|
||||
/**
|
||||
* A list of custom tags.
|
||||
*
|
||||
* @default []
|
||||
*/
|
||||
readonly customTags?: string[];
|
||||
|
||||
/**
|
||||
* If set, the schema service would load schema content on-demand with 'fetch' if available
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly enableSchemaRequest?: boolean;
|
||||
|
||||
/**
|
||||
* If true, formatting using Prettier is enabled. Setting this to `false` does **not** exclude
|
||||
* Prettier from the bundle.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly format?: boolean;
|
||||
|
||||
/**
|
||||
* If set, enable hover typs based the JSON schema.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
readonly hover?: boolean;
|
||||
|
||||
/**
|
||||
* If set, the validator will be enabled and perform syntax validation as well as schema
|
||||
* based validation.
|
||||
*/
|
||||
readonly validate?: boolean;
|
||||
|
||||
/**
|
||||
* A list of known schemas and/or associations of schemas to file names.
|
||||
*/
|
||||
readonly schemas?: SchemasSettings[];
|
||||
|
||||
/**
|
||||
* If set, the schema service would load schema content on-demand with 'fetch' if available
|
||||
*/
|
||||
readonly enableSchemaRequest?: boolean;
|
||||
/**
|
||||
* If specified, this prefix will be added to all on demand schema requests
|
||||
*/
|
||||
readonly prefix?: string;
|
||||
/**
|
||||
* Whether or not kubernetes yaml is supported
|
||||
* If true, a different diffing algorithm is used to generate error messages.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
readonly isKubernetes?: boolean;
|
||||
|
||||
/**
|
||||
* A list of custom tags.
|
||||
* If specified, this prefix will be added to all on demand schema requests
|
||||
*
|
||||
* @default undefined
|
||||
* @deprecated
|
||||
*/
|
||||
readonly customTags?: string[];
|
||||
readonly prefix?: string;
|
||||
|
||||
readonly format?: 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;
|
||||
|
||||
/**
|
||||
* The YAML version to use for parsing.
|
||||
*
|
||||
* @default '1.2'
|
||||
*/
|
||||
readonly yamlVersion?: '1.1' | '1.2';
|
||||
}
|
||||
|
||||
export interface LanguageServiceDefaults {
|
||||
|
|
|
|||
6229
package-lock.json
generated
6229
package-lock.json
generated
File diff suppressed because it is too large
Load diff
10
package.json
10
package.json
|
|
@ -39,12 +39,12 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"@types/json-schema": "^7.0.0",
|
||||
"js-yaml": "^4.0.0",
|
||||
"jsonc-parser": "^3.0.0",
|
||||
"path-browserify": "^1.0.0",
|
||||
"prettier": "2.0.5",
|
||||
"vscode-languageserver-textdocument": "^1.0.0",
|
||||
"vscode-languageserver-types": "^3.0.0",
|
||||
"yaml-language-server-parser": "^0.1.0"
|
||||
"yaml": "^2.0.0-8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"monaco-editor": ">=0.22"
|
||||
|
|
@ -52,15 +52,15 @@
|
|||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^4.0.0",
|
||||
"@typescript-eslint/parser": "^4.0.0",
|
||||
"esbuild": "^0.12.0",
|
||||
"esbuild": "^0.13.0",
|
||||
"eslint": "^7.0.0",
|
||||
"eslint-config-remcohaszing": "^3.0.0",
|
||||
"husky": "^7.0.0",
|
||||
"lint-staged": "^11.0.0",
|
||||
"monaco-editor": "^0.27.0",
|
||||
"monaco-editor": "^0.29.0",
|
||||
"type-fest": "^2.0.0",
|
||||
"typescript": "^4.0.0",
|
||||
"yaml-language-server": "^0.22.0"
|
||||
"yaml-language-server": "^1.0.0"
|
||||
},
|
||||
"resolutions": {},
|
||||
"lint-staged": {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,18 @@ import { setupMode } from './yamlMode';
|
|||
|
||||
// --- YAML configuration and defaults ---------
|
||||
|
||||
const diagnosticDefault: languages.yaml.DiagnosticsOptions = {
|
||||
completion: true,
|
||||
customTags: [],
|
||||
enableSchemaRequest: false,
|
||||
format: true,
|
||||
isKubernetes: false,
|
||||
hover: true,
|
||||
schemas: [],
|
||||
validate: true,
|
||||
yamlVersion: '1.2',
|
||||
};
|
||||
|
||||
export function createLanguageServiceDefaults(
|
||||
initialDiagnosticsOptions: languages.yaml.DiagnosticsOptions,
|
||||
): languages.yaml.LanguageServiceDefaults {
|
||||
|
|
@ -25,7 +37,7 @@ export function createLanguageServiceDefaults(
|
|||
},
|
||||
|
||||
setDiagnosticsOptions(options) {
|
||||
diagnosticsOptions = options || {};
|
||||
diagnosticsOptions = { ...diagnosticDefault, ...options };
|
||||
onDidChange.fire(languageServiceDefaults);
|
||||
},
|
||||
};
|
||||
|
|
@ -33,12 +45,6 @@ export function createLanguageServiceDefaults(
|
|||
return languageServiceDefaults;
|
||||
}
|
||||
|
||||
const diagnosticDefault: languages.yaml.DiagnosticsOptions = {
|
||||
validate: true,
|
||||
schemas: [],
|
||||
enableSchemaRequest: false,
|
||||
};
|
||||
|
||||
const yamlDefaults = createLanguageServiceDefaults(diagnosticDefault);
|
||||
|
||||
// Export API
|
||||
|
|
|
|||
|
|
@ -34,15 +34,11 @@ export interface YAMLWorker {
|
|||
|
||||
export function createYAMLWorker(
|
||||
ctx: worker.IWorkerContext,
|
||||
{ enableSchemaRequest, isKubernetes = false, languageSettings, prefix = '' }: ICreateData,
|
||||
{ enableSchemaRequest, languageSettings, prefix = '' }: ICreateData,
|
||||
): YAMLWorker {
|
||||
const service = (url: string): Promise<string> => defaultSchemaRequestService(`${prefix}${url}`);
|
||||
const languageService = getLanguageService(enableSchemaRequest && service, null, null, null);
|
||||
languageService.configure({
|
||||
...languageSettings,
|
||||
hover: true,
|
||||
isKubernetes,
|
||||
});
|
||||
languageService.configure(languageSettings);
|
||||
|
||||
const getTextDocument = (uri: string): TextDocument => {
|
||||
const models = ctx.getMirrorModels();
|
||||
|
|
@ -58,14 +54,14 @@ export function createYAMLWorker(
|
|||
doValidation(uri) {
|
||||
const document = getTextDocument(uri);
|
||||
if (document) {
|
||||
return languageService.doValidation(document, isKubernetes);
|
||||
return languageService.doValidation(document, languageSettings.isKubernetes);
|
||||
}
|
||||
return [];
|
||||
},
|
||||
|
||||
doComplete(uri, position) {
|
||||
const document = getTextDocument(uri);
|
||||
return languageService.doComplete(document, position, isKubernetes);
|
||||
return languageService.doComplete(document, position, languageSettings.isKubernetes);
|
||||
},
|
||||
|
||||
doHover(uri, position) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue