mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-06-24 00:51:47 +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/language/yaml': '../lib/dev',
|
||||
vs: '../node_modules/monaco-editor-core/dev/vs',
|
||||
prettier: '../node_modules/prettier',
|
||||
};
|
||||
if (document.location.protocol === 'http:') {
|
||||
// Add support for running local http server
|
||||
|
|
@ -51,6 +52,8 @@
|
|||
require([
|
||||
'vs/basic-languages/monaco.contribution',
|
||||
'vs/language/yaml/monaco.contribution',
|
||||
'prettier/standalone',
|
||||
'prettier/parser-yaml',
|
||||
], function() {
|
||||
const yaml = `p1: `;
|
||||
const modelUri = monaco.Uri.parse('a://b/foo.json');
|
||||
|
|
@ -68,6 +71,7 @@
|
|||
hover: true,
|
||||
completion: true,
|
||||
validate: true,
|
||||
format: true,
|
||||
schemas: [
|
||||
{
|
||||
uri: 'http://myserver/foo-schema.json', // id of the first schema
|
||||
|
|
|
|||
|
|
@ -35,11 +35,12 @@ export class YAMLFormatter {
|
|||
|
||||
try {
|
||||
const prettier = require('prettier/standalone');
|
||||
const parser = require('prettier/parser-yaml');
|
||||
const text = document.getText();
|
||||
|
||||
const formatted = prettier.format(
|
||||
text,
|
||||
Object.assign(options, { parser: 'yaml' })
|
||||
Object.assign(options, { parser: 'yaml', plugins: [parser] })
|
||||
);
|
||||
|
||||
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
|
||||
*/
|
||||
readonly isKubernetes?: boolean;
|
||||
|
||||
readonly format?: boolean;
|
||||
}
|
||||
|
||||
export interface LanguageServiceDefaults {
|
||||
|
|
|
|||
Loading…
Reference in a new issue