Skip to content

Commit

Permalink
Merge pull request #69 from bradymholt/more-options
Browse files Browse the repository at this point in the history
Add new options: noExtraLine, typeCase, and wrapComment
  • Loading branch information
bradymholt authored Oct 11, 2023
2 parents d9501a5 + 3776080 commit 337cc3b
Show file tree
Hide file tree
Showing 4 changed files with 1,580 additions and 10 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ This extension has the following configuration settings:
* `pgFormatter.commaBreak` - In insert statement, add a newline after each comma (Default: `false`)
* `pgFormatter.commaEnd` - Use trailing comma in parameter list (Default: `true`)
* `pgFormatter.noComment` - Remove any comments (Default: `false`)
* `pgFormatter.functionCase` - Case of the function names (Options: ["unchanged", "lowercase", "uppercase", "capitalize"]; Default: `"unchanged"`)
* `pgFormatter.noGrouping` - Add a newline between statements in transaction regroupement (Default: `false`)
* `pgFormatter.keywordCase` - Case of the reserved keywords (Options: ["unchanged", "lowercase", "uppercase", "capitalize"]; Default: `"uppercase"`)
* `pgFormatter.noExtraLine` - Do not add an extra empty line at end of the output (Default: `false`)
* `pgFormatter.functionCase` - Case of the function names (Options: ["unchanged", "lowercase", "uppercase", "capitalize"]; Default: `"unchanged"`)
* `pgFormatter.keywordCase` - Case used for reserved keywords (Options: ["unchanged", "lowercase", "uppercase", "capitalize"]; Default: `"uppercase"`)
* `pgFormatter.typeCase` - Case used for data types (Options: ["unchanged", "lowercase", "uppercase", "capitalize"]; Default: `"lowercase"`)
* `pgFormatter.formatType` - Use another formatting type for some statements (Default: `false`)
* `pgFormatter.wrapLimit` - Wrap queries at a certain length
* `pgFormatter.wrapComment` - When wrapLimit is specified, comments will be wrapped too (Default: `false`)
* `pgFormatter.placeholder` - Regex to find code that must not be changed
* `pgFormatter.extraFunction` - Path to file containing a list of function names to use the same formatting as PostgreSQL internal functions
* `pgFormatter.noSpaceFunction` - Remove the space character between a function call and the open parenthesis that follows (Default: `true`)
Expand Down
36 changes: 28 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,17 @@
"type": "boolean",
"default": false,
"description": "Remove any comments"
},
"pgFormatter.noGrouping": {
"type": "boolean",
"default": false,
"description": "Add a newline between statements in transaction regroupement"
},
"pgFormatter.noExtraLine": {
"type": "boolean",
"default": false,
"description": "Do not add an extra empty line at end of the file"
},
"pgFormatter.functionCase": {
"type": "string",
"default": "unchanged",
Expand All @@ -109,12 +119,7 @@
"uppercase",
"capitalize"
],
"description": "Case of the function names"
},
"pgFormatter.noGrouping": {
"type": "boolean",
"default": false,
"description": "Add a newline between statements in transaction regroupement"
"description": "Case to be used for function names"
},
"pgFormatter.keywordCase": {
"type": "string",
Expand All @@ -125,7 +130,18 @@
"uppercase",
"capitalize"
],
"description": "Case of the reserved keywords"
"description": "Case to be used for reserved keywords"
},
"pgFormatter.typeCase": {
"type": "string",
"default": ".lowercase",
"enum": [
"unchanged",
"lowercase",
"uppercase",
"capitalize"
],
"description": "Case to be used for data type names"
},
"pgFormatter.formatType": {
"type": "boolean",
Expand All @@ -136,6 +152,10 @@
"type": "number",
"description": "Wrap queries at a certain length"
},
"pgFormatter.wrapComment": {
"type": "boolean",
"description": "With pgFormatter.wrapLimit specified, apply reformatting to comments"
},
"pgFormatter.placeholder": {
"type": "string",
"default": null,
Expand Down Expand Up @@ -189,6 +209,6 @@
"vscode-test": "^1.5.0"
},
"dependencies": {
"psqlformat": "1.18.3"
"psqlformat": "1.20.0"
}
}
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export function getFormattedText(
if (config.keywordCase != null) {
formattingOptions.keywordCase = CaseOptionEnum[<keyof typeof CaseOptionEnum>config.keywordCase];
}
if (config.typeCase != null) {
formattingOptions.typeCase = CaseOptionEnum[<keyof typeof CaseOptionEnum>config.typeCase];
}

if (!formattingOptions.spaces) {
if (options.tabSize) {
Expand Down
Loading

0 comments on commit 337cc3b

Please sign in to comment.