Monaco-editor: provideDocumentFormattingEdits still uses default formatter

Created on 22 May 2018  路  4Comments  路  Source: microsoft/monaco-editor

I am providing my own custom json formatter with provideDocumentFormattingEdits. However, when I use it, the default json formatter is still active and so my formatting gets overridden. Can I set my formatter as the only formatter somehow?

provideDocumentFormattingEdits(model: Monaco.editor.ITextModel, options: Monaco.languages.FormattingOptions, token: Monaco.CancellationToken): Monaco.languages.TextEdit[] {
  return [
    {
      range: model.getFullModelRange(),
      text: stringify(JSON.parse(model.getValue())),
    },
  ];
},

cc @aeschli from https://github.com/Microsoft/monaco-json

monaco-json

Most helpful comment

@nesterone Has this issue been resolved?

All 4 comments

That's currently not possible. We would need a new setting json.format.enable to the json monaco api. If you want to make a PR, that would be awesome.

I see. What's the suggested way to get JSON syntax highlighting and completion but a custom formatter until that flag is added?

FYI: I'm going to try with extending monaco api with json.format.enable

@nesterone Has this issue been resolved?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandalorian picture brandalorian  路  3Comments

galyech picture galyech  路  3Comments

zeegin picture zeegin  路  3Comments

PinkyJie picture PinkyJie  路  3Comments

Panhaiwei picture Panhaiwei  路  3Comments