Skip to content

Commit

Permalink
Use sql-formatter in sql formatting (#426)
Browse files Browse the repository at this point in the history
- Update sql format to use the sql-formatter library.
  • Loading branch information
prajwal-pai77 authored Oct 15, 2024
1 parent 2fb868d commit 0c76f89
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 2 deletions.
82 changes: 81 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
"react-syntax-highlighter": "^15.5.0",
"react-tooltip": "^5.26.0",
"shelljs": "^0.8.5",
"sql-formatter": "^15.4.2",
"stream-json": "^1.8.0",
"uuid": "^9.0.1",
"vscode-json-languageservice": "^5.3.11"
Expand Down
9 changes: 8 additions & 1 deletion src/commands/sqlpp/sqlppFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import * as vscode from 'vscode';
import { format } from 'sql-formatter';

export const sqlppFormatter = (document: vscode.TextDocument): vscode.TextEdit[] => {
const fullText = document.getText();
const formattedText = processText(fullText, 4);

const formattedText = format(fullText, {
language: 'n1ql',
tabWidth: 4,
keywordCase: 'upper',
});

const textEdit = new vscode.TextEdit(
new vscode.Range(
document.positionAt(0),
Expand Down

0 comments on commit 0c76f89

Please sign in to comment.