Skip to content

Commit

Permalink
Formatter settings
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Sep 21, 2024
1 parent 4b89edc commit 296a251
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/contributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,30 @@
"properties": {
"vscode-db2i.sqlFormat.identifierCase": {
"type": "string",
"description": "SQL identifiers",
"description": "Format SQL identifiers into a certain case",
"default": "preserve",
"enum": [
"lower",
"upper",
"preserve"
],
"enumDescriptions": [
"Format SQL identifiers in lowercase",
"Format SQL identifiers in uppercase",
"Preserve the current formatting of SQL identifiers"
]
},
"vscode-db2i.sqlFormat.keywordCase": {
"type": "string",
"description": "SQL keywords",
"description": "Format SQL keywords into a certain case",
"default": "lower",
"enum": [
"lower",
"upper"
],
"enumDescriptions": [
"Format reserved SQL keywords in lowercase",
"Format reserved SQL keywords in uppercase"
]
},
"vscode-db2i.sqlFormat.spaceBetweenStatements": {
"type": "string",
"description": "Add space between statements.",
"default": "true",
"enum": [
"true",
"false"
]
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/language/providers/formatProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ export const formatProvider = languages.registerDocumentFormattingEditProvider({
async provideDocumentFormattingEdits(document, options, token) {
const identifierCase: CaseOptions = <CaseOptions>(Configuration.get(`sqlFormat.identifierCase`) || `preserve`);
const keywordCase: CaseOptions = <CaseOptions>(Configuration.get(`sqlFormat.keywordCase`) || `lower`);
const spaceBetweenStatements: string = (Configuration.get(`sqlFormat.spaceBetweenStatements`) || `false`);
const formatted = formatSql(
document.getText(),
{
indentWidth: options.tabSize,
identifierCase: identifierCase,
keywordCase: keywordCase,
spaceBetweenStatements: true
identifierCase,
keywordCase,
spaceBetweenStatements: spaceBetweenStatements === `true`
}
);

Expand Down

0 comments on commit 296a251

Please sign in to comment.