Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql-formatter or sqlfmt for auto-formatting sql #200

Open
coolaj86 opened this issue Sep 18, 2024 · 0 comments
Open

sql-formatter or sqlfmt for auto-formatting sql #200

coolaj86 opened this issue Sep 18, 2024 · 0 comments

Comments

@coolaj86
Copy link
Member

coolaj86 commented Sep 18, 2024

Contenders

sqlfmt (go)

Releases available at:

let g:sqlfmt_command = "sqlfmt"
let g:sqlfmt_options = ""

TODO: figure out to get it to format without replacing the file with the error message on error (maybe it's outputting errors to stdout instead of stderr?) maddyblue/sqlfmt#69

sql-formatter (node)

Since we gotta have node anyway...

{
  "keywordCase": "upper",
  "identifierCase": "lower",
  "newlineBeforeSemicolon": true
}
let g:sqlfmt_command = "sql-formatter"
let g:sqlfmt_options = "-l postgresql -c ./.sql-formatter.json"
let g:sqlfmt_auto = 1

sql-parser-cst

https://github.com/nene/sql-parser-cst

Vim Plugin

autocmd

" Auto-format SQL files with sqlfmt on save
autocmd BufWritePre *.sql execute ':silent %!sqlfmt'

babarot/vim-sqlfmt

It seems that this is a generic formatter tool that could work with any formatter that follows the stdout / stderr conventions:

git clone https://github.com/babarot/vim-sqlfmt.git ~/.vim/pack/plugins/start/vim-sqlfmt
@coolaj86 coolaj86 changed the title sqlfmt for auto-formatting sql sql-formatter or sqlfmt for auto-formatting sql Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant