Add sqlformat support.
This commit is contained in:
parent
3c50ddb506
commit
b8173cde86
@ -238,6 +238,9 @@ Here is a list of formatprograms that are supported by default, and thus will be
|
|||||||
* `shfmt` for __Shell__.
|
* `shfmt` for __Shell__.
|
||||||
A shell formatter written in Go supporting POSIX Shell, Bash and mksh that can be installed with `go get -u mvdan.cc/sh/cmd/shfmt`. See https://github.com/mvdan/sh for more info.
|
A shell formatter written in Go supporting POSIX Shell, Bash and mksh that can be installed with `go get -u mvdan.cc/sh/cmd/shfmt`. See https://github.com/mvdan/sh for more info.
|
||||||
|
|
||||||
|
* `sqlformat` for __SQL__.
|
||||||
|
Install `sqlparse` with `pip`.
|
||||||
|
|
||||||
|
|
||||||
## Help, the formatter doesn't work as expected!
|
## Help, the formatter doesn't work as expected!
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ if !exists('g:formatter_yapf_style')
|
|||||||
endif
|
endif
|
||||||
if !exists('g:formatdef_yapf')
|
if !exists('g:formatdef_yapf')
|
||||||
let s:configfile_def = "'yapf -l '.a:firstline.'-'.a:lastline"
|
let s:configfile_def = "'yapf -l '.a:firstline.'-'.a:lastline"
|
||||||
let s:noconfigfile_def = "'yapf --style=\"{based_on_style:'.g:formatter_yapf_style.',indent_width:'.&shiftwidth.(&textwidth ? ',column_limit:'.&textwidth : '').'}\" -l '.a:firstline.'-'.a:lastline"
|
let s:noconfigfile_def = "'yapf --style=\"{based_on_style:'.g:formatter_yapf_style.',indent_width:'.shiftwidth().(&textwidth ? ',column_limit:'.&textwidth : '').'}\" -l '.a:firstline.'-'.a:lastline"
|
||||||
let g:formatdef_yapf = "g:YAPFFormatConfigFileExists() ? (" . s:configfile_def . ") : (" . s:noconfigfile_def . ")"
|
let g:formatdef_yapf = "g:YAPFFormatConfigFileExists() ? (" . s:configfile_def . ") : (" . s:noconfigfile_def . ")"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -452,7 +452,7 @@ endif
|
|||||||
|
|
||||||
" Fortran
|
" Fortran
|
||||||
if !exists('g:formatdef_fprettify')
|
if !exists('g:formatdef_fprettify')
|
||||||
let g:formatdef_fprettify = '"fprettify --no-report-errors --indent=".&shiftwidth'
|
let g:formatdef_fprettify = '"fprettify --no-report-errors --indent=".shiftwidth()'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists('g:formatters_fortran')
|
if !exists('g:formatters_fortran')
|
||||||
@ -476,3 +476,11 @@ endif
|
|||||||
if !exists('g:formatters_sh')
|
if !exists('g:formatters_sh')
|
||||||
let g:formatters_sh = ['shfmt']
|
let g:formatters_sh = ['shfmt']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" SQL
|
||||||
|
if !exists('g:formatdef_sqlformat')
|
||||||
|
let g:formatdef_sqlformat = '"sqlformat --reindent --indent_width ".shiftwidth()." --keywords upper --identifiers lower -"'
|
||||||
|
endif
|
||||||
|
if !exists('g:formatters_sql')
|
||||||
|
let g:formatters_sql = ['sqlformat']
|
||||||
|
endif
|
||||||
|
1
samples/test.sql
Normal file
1
samples/test.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
selECT * FROM foo WHERE id IN (SELECT id FROM bar);
|
Loading…
Reference in New Issue
Block a user