Skip to content

Commit

Permalink
Only add the "format document with sqlfluff" button when using dbt-co…
Browse files Browse the repository at this point in the history
…re-interface
  • Loading branch information
barrywhart committed Jan 2, 2024
1 parent 937724e commit 67ba58d
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,20 @@ export const activate = (context: vscode.ExtensionContext) => {
};
context.subscriptions.push(vscode.commands.registerCommand(fixCommand, fixCommandHandler));

// Adds a "Fix document with sqlfluff" button to the lower right corner of
// the VS Code window
const customStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
customStatusBarItem.text = "$(pencil)";
customStatusBarItem.tooltip = "Fix document with sqlfluff";
customStatusBarItem.command = fixCommand;
customStatusBarItem.show();

const formatSelection = "sqlfluff.format.selection";
if (!Configuration.dbtInterfaceEnabled()) {
if (Configuration.dbtInterfaceEnabled()) {
// When dbt-core-interface is enabled, adds a "Format document with
// sqlfluff" button to the lower right corner of the VS Code window. Use
// of the word "format" is deliberate, as the button hits the
// dbt-core-interface "/format" endpoint, equivalent to "sqlfluff format".
const customStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
customStatusBarItem.text = "$(pencil)";
customStatusBarItem.tooltip = "Format document with sqlfluff";
customStatusBarItem.command = fixCommand;
customStatusBarItem.show();
}
else {
// When dbt-core-interface is not enabled, adds a "format selection" action.
const formatSelection = "sqlfluff.format.selection";
const formatSelectionHandler = async () => {
if (vscode.window.activeTextEditor) {
// Check if available language
Expand Down

0 comments on commit 67ba58d

Please sign in to comment.