mtxr / vscode-sqltools

Database management for VSCode
https://vscode-sqltools.mteixeira.dev?utm_source=github&utm_medium=homepage-link
MIT License
1.51k stars 303 forks source link

Formatter should respect indentation #819

Open ngdangtu-vn opened 3 years ago

ngdangtu-vn commented 3 years ago

Is your feature request related to a problem? Please describe. The way Formatter killed off all my indentation cause me a lot of trouble in reading the code. Please don't do that.

-- Origin
CREATE TABLE contact_groups(
    contact_id INTEGER,
    group_id INTEGER,
    PRIMARY KEY (contact_id, group_id),
    FOREIGN KEY (contact_id)
        REFERENCES contacts (contact_id)
            ON DELETE CASCADE
            ON UPDATE NO ACTION,
    FOREIGN KEY (group_id)
        REFERENCES groups (group_id)
            ON DELETE CASCADE
            ON UPDATE NO ACTION
);
-- Formatted
CREATE TABLE contact_groups(
    contact_id INTEGER,
    group_id INTEGER,
    PRIMARY KEY (contact_id, group_id),
    FOREIGN KEY (contact_id) REFERENCES contacts (contact_id) ON DELETE CASCADE ON UPDATE NO ACTION,
    FOREIGN KEY (group_id) REFERENCES groups (group_id) ON DELETE CASCADE ON UPDATE NO ACTION
);

Describe the solution you'd like I simply want the formatter respect my indentation. Therefore I would like to add this option:

{
    "sqltools.format": {
        "language": "sql",
        "reservedWordCase": "upper",
        "linesBetweenQueries": 3,
        "indentation": "preserve | nested | crowed"
    }
}

Where as:

BenGinders commented 3 years ago

This would be great if it could be added, currently indentation type or amount is not valid in the sqltools.format setting