senkenn / sqlsurge

Visual Studio Code extension for SQL language server
https://marketplace.visualstudio.com/items?itemName=senken.sqlsurge
MIT License
18 stars 0 forks source link

Format with indent #49

Closed senkenn closed 5 months ago

senkenn commented 5 months ago

Current

async fn complete_todo(pool: &PgPool, id: i64) -> anyhow::Result<bool> {
    let rows_affected = sqlx::query!(
        r#"
UPDATE todos
SET
  done = TRUE
WHERE
  id = $1
        "#,
        id
    )
    .execute(pool)
    .await?
    .rows_affected();

    Ok(rows_affected > 0)
}

Expected

async fn complete_todo(pool: &PgPool, id: i64) -> anyhow::Result<bool> {
    let rows_affected = sqlx::query!(
        r#"
        UPDATE todos
        SET
            done = TRUE
        WHERE
            id = $1
        "#,
        id
    )
    .execute(pool)
    .await?
    .rows_affected();

    Ok(rows_affected > 0)
}
senkenn commented 5 months ago

How about? @Veetaha

Veetaha commented 5 months ago

Yeah, I agree. Best would be to indent SQL relative to the opening r#"

senkenn commented 5 months ago

Thank you for your opinion. @Veetaha I decided to create an option config like sqlsurge.formatSqlWithIndent: boolean. The default is false(= no indent) now but may be changed depending on future user feedback.

senkenn commented 5 months ago

This feature can be used in v0.5.3 :rocket: You can enable format with indent by sqlsurge.formatSql.indent: true.