Skip to content

Commit

Permalink
feat: implemented provideDocumentRangeFormattingEdits
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jun 9, 2022
1 parent 73f046d commit 0e64a81
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/monaco/ls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,21 @@ export async function setupLs(modelsMap: Ref<Map<string, monaco.editor.ITextMode
}
},
}),
monaco.languages.registerDocumentRangeFormattingEditProvider(lang, {
provideDocumentRangeFormattingEdits: async (model, range, options) => {
const document = documents.get(model);
if (document) {
const codeResult = await ds.format(
document,
monaco2code.asFormattingOptions(options),
monaco2code.asRange(range),
);
if (codeResult) {
return codeResult.map(code2monaco.asTextEdit);
}
}
},
}),
monaco.languages.registerCompletionItemProvider(lang, {
// https://github.com/johnsoncodehk/volar/blob/2f786182250d27e99cc3714fbfc7d209616e2289/packages/vue-language-server/src/registers/registerlanguageFeatures.ts#L57
triggerCharacters: '!@#$%^&*()_+-=`~{}|[]\:";\'<>?,./ '.split(''),
Expand Down

0 comments on commit 0e64a81

Please sign in to comment.