monaco-sql-languages
monaco-sql-languages copied to clipboard
Sql Formatter support
Hi there, thanks for this lib!
I have added support for formatting, lmk if you'd like a PR
it's pretty simple, something like this:
import { languages } from 'monaco-editor/esm/vs/editor/editor.api';
import { format } from 'sql-formatter';
languages.registerDocumentFormattingEditProvider('sql', {
provideDocumentFormattingEdits(model, options) {
const formatted = format(model.getValue(), {
indentStyle: 'standard',
});
return [
{
range: model.getFullModelRange(),
text: formatted,
},
];
},
});
languages.registerDocumentRangeFormattingEditProvider('sql', {
provideDocumentRangeFormattingEdits(model, range, options) {
const formatted = format(model.getValueInRange(range), {
indentStyle: 'standard',
});
return [
{
range: range,
text: formatted,
},
];
},
});
Hi, @salvoravida, we are very welcome your contribution. But there needs to integrate of many kinds of SQL.