mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-07-06 19:40:55 +00:00
Update prettier to match yaml-language-server
Since both yaml-language-server and prettier are included in the bundle, their versions should match for best compatibility. Also code has been formatted using the updated prettier.
This commit is contained in:
parent
3762a98af0
commit
5fd08c73ed
7 changed files with 38 additions and 41 deletions
|
|
@ -15,7 +15,7 @@
|
||||||
<code id="path"></code>
|
<code id="path"></code>
|
||||||
<div
|
<div
|
||||||
id="container"
|
id="container"
|
||||||
style="width:800px;height:600px;border:1px solid grey"
|
style="width: 800px; height: 600px; border: 1px solid grey;"
|
||||||
></div>
|
></div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
'vs/language/yaml/monaco.contribution',
|
'vs/language/yaml/monaco.contribution',
|
||||||
'prettier/standalone',
|
'prettier/standalone',
|
||||||
'prettier/parser-yaml',
|
'prettier/parser-yaml',
|
||||||
], function() {
|
], function () {
|
||||||
const yaml = `p1: `;
|
const yaml = `p1: `;
|
||||||
const modelUri = monaco.Uri.parse('a://b/foo.json');
|
const modelUri = monaco.Uri.parse('a://b/foo.json');
|
||||||
const editor = monaco.editor.create(
|
const editor = monaco.editor.create(
|
||||||
|
|
@ -102,7 +102,9 @@
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
require(['vs/editor/contrib/quickOpen/quickOpen'], async quickOpen => {
|
require(['vs/editor/contrib/quickOpen/quickOpen'], async (
|
||||||
|
quickOpen
|
||||||
|
) => {
|
||||||
const NEVER_CANCEL_TOKEN = {
|
const NEVER_CANCEL_TOKEN = {
|
||||||
isCancellationRequested: false,
|
isCancellationRequested: false,
|
||||||
onCancellationRequested: () => Event.NONE,
|
onCancellationRequested: () => Event.NONE,
|
||||||
|
|
@ -122,7 +124,7 @@
|
||||||
if (symbol && symbol.children && symbol.children.length) {
|
if (symbol && symbol.children && symbol.children.length) {
|
||||||
target =
|
target =
|
||||||
_recur(
|
_recur(
|
||||||
symbol.children.find(child =>
|
symbol.children.find((child) =>
|
||||||
child.range.containsPosition(position)
|
child.range.containsPosition(position)
|
||||||
)
|
)
|
||||||
) || symbol;
|
) || symbol;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
"bundle:esm": "node ./scripts/bundle-esm",
|
"bundle:esm": "node ./scripts/bundle-esm",
|
||||||
"build": "yarn compile && yarn bundle",
|
"build": "yarn compile && yarn bundle",
|
||||||
"prepare": "husky install && yarn build",
|
"prepare": "husky install && yarn build",
|
||||||
"lint": "prettier \"**/*.{css,js,json,jsx,html,md,ts}\" --check"
|
"lint": "prettier --check ."
|
||||||
},
|
},
|
||||||
"main": "./lib/esm/monaco.contribution.js",
|
"main": "./lib/esm/monaco.contribution.js",
|
||||||
"module": "./lib/esm/monaco.contribution.js",
|
"module": "./lib/esm/monaco.contribution.js",
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
"monaco-editor-core": "^0.21.2",
|
"monaco-editor-core": "^0.21.2",
|
||||||
"monaco-languages": "^2.1.1",
|
"monaco-languages": "^2.1.1",
|
||||||
"monaco-plugin-helpers": "^1.0.3",
|
"monaco-plugin-helpers": "^1.0.3",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "2.0.5",
|
||||||
"requirejs": "^2.3.6",
|
"requirejs": "^2.3.6",
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
"typescript": "^4.2.3",
|
"typescript": "^4.2.3",
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
"semi": true
|
"semi": true
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"src/*.{json,scss,html,ts,js,jsx}|scripts/*.js": [
|
"*.{css,json,md,html,ts,js,jsx,yaml}": [
|
||||||
"prettier --write"
|
"prettier --write"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ function bundleOne(moduleId, exclude) {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
function() {
|
function () {
|
||||||
const devFilePath = path.join(REPO_ROOT, 'lib/dev/' + moduleId + '.js');
|
const devFilePath = path.join(REPO_ROOT, 'lib/dev/' + moduleId + '.js');
|
||||||
const minFilePath = path.join(REPO_ROOT, 'lib/min/' + moduleId + '.js');
|
const minFilePath = path.join(REPO_ROOT, 'lib/min/' + moduleId + '.js');
|
||||||
const fileContents = fs.readFileSync(devFilePath).toString();
|
const fileContents = fs.readFileSync(devFilePath).toString();
|
||||||
|
|
|
||||||
|
|
@ -58,13 +58,13 @@ export class DiagnosticsAdapter {
|
||||||
|
|
||||||
this._disposables.push(monaco.editor.onDidCreateModel(onModelAdd));
|
this._disposables.push(monaco.editor.onDidCreateModel(onModelAdd));
|
||||||
this._disposables.push(
|
this._disposables.push(
|
||||||
monaco.editor.onWillDisposeModel(model => {
|
monaco.editor.onWillDisposeModel((model) => {
|
||||||
onModelRemoved(model);
|
onModelRemoved(model);
|
||||||
this._resetSchema(model.uri);
|
this._resetSchema(model.uri);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
this._disposables.push(
|
this._disposables.push(
|
||||||
monaco.editor.onDidChangeModelLanguage(event => {
|
monaco.editor.onDidChangeModelLanguage((event) => {
|
||||||
onModelRemoved(event.model);
|
onModelRemoved(event.model);
|
||||||
onModelAdd(event.model);
|
onModelAdd(event.model);
|
||||||
this._resetSchema(event.model.uri);
|
this._resetSchema(event.model.uri);
|
||||||
|
|
@ -72,8 +72,8 @@ export class DiagnosticsAdapter {
|
||||||
);
|
);
|
||||||
|
|
||||||
this._disposables.push(
|
this._disposables.push(
|
||||||
defaults.onDidChange(_ => {
|
defaults.onDidChange((_) => {
|
||||||
monaco.editor.getModels().forEach(model => {
|
monaco.editor.getModels().forEach((model) => {
|
||||||
if (model.getModeId() === this._languageId) {
|
if (model.getModeId() === this._languageId) {
|
||||||
onModelRemoved(model);
|
onModelRemoved(model);
|
||||||
onModelAdd(model);
|
onModelAdd(model);
|
||||||
|
|
@ -95,28 +95,28 @@ export class DiagnosticsAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public dispose(): void {
|
public dispose(): void {
|
||||||
this._disposables.forEach(d => d && d.dispose());
|
this._disposables.forEach((d) => d && d.dispose());
|
||||||
this._disposables = [];
|
this._disposables = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
private _resetSchema(resource: Uri): void {
|
private _resetSchema(resource: Uri): void {
|
||||||
this._worker().then(worker => {
|
this._worker().then((worker) => {
|
||||||
worker.resetSchema(resource.toString());
|
worker.resetSchema(resource.toString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _doValidate(resource: Uri, languageId: string): void {
|
private _doValidate(resource: Uri, languageId: string): void {
|
||||||
this._worker(resource)
|
this._worker(resource)
|
||||||
.then(worker => {
|
.then((worker) => {
|
||||||
return worker.doValidation(resource.toString()).then(diagnostics => {
|
return worker.doValidation(resource.toString()).then((diagnostics) => {
|
||||||
const markers = diagnostics.map(d => toDiagnostics(resource, d));
|
const markers = diagnostics.map((d) => toDiagnostics(resource, d));
|
||||||
const model = monaco.editor.getModel(resource);
|
const model = monaco.editor.getModel(resource);
|
||||||
if (model.getModeId() === languageId) {
|
if (model.getModeId() === languageId) {
|
||||||
monaco.editor.setModelMarkers(model, languageId, markers);
|
monaco.editor.setModelMarkers(model, languageId, markers);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(undefined, err => {
|
.then(undefined, (err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -308,10 +308,10 @@ export class CompletionAdapter
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return this._worker(resource)
|
return this._worker(resource)
|
||||||
.then(worker => {
|
.then((worker) => {
|
||||||
return worker.doComplete(resource.toString(), fromPosition(position));
|
return worker.doComplete(resource.toString(), fromPosition(position));
|
||||||
})
|
})
|
||||||
.then(info => {
|
.then((info) => {
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +325,7 @@ export class CompletionAdapter
|
||||||
);
|
);
|
||||||
|
|
||||||
const items: monaco.languages.CompletionItem[] = info.items.map(
|
const items: monaco.languages.CompletionItem[] = info.items.map(
|
||||||
entry => {
|
(entry) => {
|
||||||
const item: monaco.languages.CompletionItem = {
|
const item: monaco.languages.CompletionItem = {
|
||||||
label: entry.label,
|
label: entry.label,
|
||||||
insertText: entry.insertText || entry.label,
|
insertText: entry.insertText || entry.label,
|
||||||
|
|
@ -416,10 +416,10 @@ export class HoverAdapter implements monaco.languages.HoverProvider {
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return this._worker(resource)
|
return this._worker(resource)
|
||||||
.then(worker => {
|
.then((worker) => {
|
||||||
return worker.doHover(resource.toString(), fromPosition(position));
|
return worker.doHover(resource.toString(), fromPosition(position));
|
||||||
})
|
})
|
||||||
.then(info => {
|
.then((info) => {
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -488,12 +488,12 @@ export class DocumentSymbolAdapter
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return this._worker(resource)
|
return this._worker(resource)
|
||||||
.then(worker => worker.findDocumentSymbols(resource.toString()))
|
.then((worker) => worker.findDocumentSymbols(resource.toString()))
|
||||||
.then(items => {
|
.then((items) => {
|
||||||
if (!items) {
|
if (!items) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return items.map(item => toDocumentSymbol(item));
|
return items.map((item) => toDocumentSymbol(item));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -507,7 +507,7 @@ function toDocumentSymbol(
|
||||||
name: item.name,
|
name: item.name,
|
||||||
kind: toSymbolKind(item.kind),
|
kind: toSymbolKind(item.kind),
|
||||||
selectionRange: toRange(item.selectionRange),
|
selectionRange: toRange(item.selectionRange),
|
||||||
children: item.children.map(child => toDocumentSymbol(child)),
|
children: item.children.map((child) => toDocumentSymbol(child)),
|
||||||
tags: [],
|
tags: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -533,10 +533,10 @@ export class DocumentFormattingEditProvider
|
||||||
): Thenable<monaco.editor.ISingleEditOperation[]> {
|
): Thenable<monaco.editor.ISingleEditOperation[]> {
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return this._worker(resource).then(worker => {
|
return this._worker(resource).then((worker) => {
|
||||||
return worker
|
return worker
|
||||||
.format(resource.toString(), null, fromFormattingOptions(options))
|
.format(resource.toString(), null, fromFormattingOptions(options))
|
||||||
.then(edits => {
|
.then((edits) => {
|
||||||
if (!edits || edits.length === 0) {
|
if (!edits || edits.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -558,14 +558,14 @@ export class DocumentRangeFormattingEditProvider
|
||||||
): Thenable<monaco.editor.ISingleEditOperation[]> {
|
): Thenable<monaco.editor.ISingleEditOperation[]> {
|
||||||
const resource = model.uri;
|
const resource = model.uri;
|
||||||
|
|
||||||
return this._worker(resource).then(worker => {
|
return this._worker(resource).then((worker) => {
|
||||||
return worker
|
return worker
|
||||||
.format(
|
.format(
|
||||||
resource.toString(),
|
resource.toString(),
|
||||||
fromRange(range),
|
fromRange(range),
|
||||||
fromFormattingOptions(options)
|
fromFormattingOptions(options)
|
||||||
)
|
)
|
||||||
.then(edits => {
|
.then((edits) => {
|
||||||
if (!edits || edits.length === 0) {
|
if (!edits || edits.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,13 @@ export class WorkerManager {
|
||||||
public getLanguageServiceWorker(...resources: Uri[]): Promise<YAMLWorker> {
|
public getLanguageServiceWorker(...resources: Uri[]): Promise<YAMLWorker> {
|
||||||
let _client: YAMLWorker;
|
let _client: YAMLWorker;
|
||||||
return this._getClient()
|
return this._getClient()
|
||||||
.then(client => {
|
.then((client) => {
|
||||||
_client = client;
|
_client = client;
|
||||||
})
|
})
|
||||||
.then(_ => {
|
.then((_) => {
|
||||||
return this._worker.withSyncedResources(resources);
|
return this._worker.withSyncedResources(resources);
|
||||||
})
|
})
|
||||||
.then(_ => _client);
|
.then((_) => _client);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _stopWorker(): void {
|
private _stopWorker(): void {
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ import * as yamlService from 'yaml-language-server';
|
||||||
|
|
||||||
let defaultSchemaRequestService;
|
let defaultSchemaRequestService;
|
||||||
if (typeof fetch !== 'undefined') {
|
if (typeof fetch !== 'undefined') {
|
||||||
defaultSchemaRequestService = function(url) {
|
defaultSchemaRequestService = function (url) {
|
||||||
return fetch(url).then(response => response.text());
|
return fetch(url).then((response) => response.text());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -674,11 +674,6 @@ prettier@2.0.5:
|
||||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
|
||||||
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==
|
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==
|
||||||
|
|
||||||
prettier@^1.19.1:
|
|
||||||
version "1.19.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
|
|
||||||
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
|
|
||||||
|
|
||||||
pump@^3.0.0:
|
pump@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
|
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue