mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-07-09 04:50:56 +00:00
fix: enable prettier formatter for umd (#2)
This commit is contained in:
parent
549e4afc5a
commit
1b31f48186
3 changed files with 8 additions and 1 deletions
|
|
@ -30,6 +30,7 @@
|
||||||
'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
|
'vs/basic-languages': '../node_modules/monaco-languages/release/dev',
|
||||||
'vs/language/yaml': '../lib/dev',
|
'vs/language/yaml': '../lib/dev',
|
||||||
vs: '../node_modules/monaco-editor-core/dev/vs',
|
vs: '../node_modules/monaco-editor-core/dev/vs',
|
||||||
|
prettier: '../node_modules/prettier',
|
||||||
};
|
};
|
||||||
if (document.location.protocol === 'http:') {
|
if (document.location.protocol === 'http:') {
|
||||||
// Add support for running local http server
|
// Add support for running local http server
|
||||||
|
|
@ -51,6 +52,8 @@
|
||||||
require([
|
require([
|
||||||
'vs/basic-languages/monaco.contribution',
|
'vs/basic-languages/monaco.contribution',
|
||||||
'vs/language/yaml/monaco.contribution',
|
'vs/language/yaml/monaco.contribution',
|
||||||
|
'prettier/standalone',
|
||||||
|
'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');
|
||||||
|
|
@ -68,6 +71,7 @@
|
||||||
hover: true,
|
hover: true,
|
||||||
completion: true,
|
completion: true,
|
||||||
validate: true,
|
validate: true,
|
||||||
|
format: true,
|
||||||
schemas: [
|
schemas: [
|
||||||
{
|
{
|
||||||
uri: 'http://myserver/foo-schema.json', // id of the first schema
|
uri: 'http://myserver/foo-schema.json', // id of the first schema
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,12 @@ export class YAMLFormatter {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const prettier = require('prettier/standalone');
|
const prettier = require('prettier/standalone');
|
||||||
|
const parser = require('prettier/parser-yaml');
|
||||||
const text = document.getText();
|
const text = document.getText();
|
||||||
|
|
||||||
const formatted = prettier.format(
|
const formatted = prettier.format(
|
||||||
text,
|
text,
|
||||||
Object.assign(options, { parser: 'yaml' })
|
Object.assign(options, { parser: 'yaml', plugins: [parser] })
|
||||||
);
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
2
src/monaco.d.ts
vendored
2
src/monaco.d.ts
vendored
|
|
@ -40,6 +40,8 @@ declare namespace monaco.languages.yaml {
|
||||||
* Whether or not kubernetes yaml is supported
|
* Whether or not kubernetes yaml is supported
|
||||||
*/
|
*/
|
||||||
readonly isKubernetes?: boolean;
|
readonly isKubernetes?: boolean;
|
||||||
|
|
||||||
|
readonly format?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LanguageServiceDefaults {
|
export interface LanguageServiceDefaults {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue