mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 20:54:26 +08:00
Add support for sqlfmt
This commit is contained in:
@@ -176,7 +176,7 @@ formatting.
|
|||||||
| SML | [smlnj](http://www.smlnj.org/) |
|
| SML | [smlnj](http://www.smlnj.org/) |
|
||||||
| Solidity | [solhint](https://github.com/protofire/solhint), [solium](https://github.com/duaraghav8/Solium) |
|
| Solidity | [solhint](https://github.com/protofire/solhint), [solium](https://github.com/duaraghav8/Solium) |
|
||||||
| Stylus | [stylelint](https://github.com/stylelint/stylelint) |
|
| Stylus | [stylelint](https://github.com/stylelint/stylelint) |
|
||||||
| SQL | [sqlint](https://github.com/purcell/sqlint) |
|
| SQL | [sqlint](https://github.com/purcell/sqlint), [sqlfmt](https://github.com/jackc/sqlfmt) |
|
||||||
| Swift | [swiftlint](https://github.com/realm/SwiftLint), [swiftformat](https://github.com/nicklockwood/SwiftFormat) |
|
| Swift | [swiftlint](https://github.com/realm/SwiftLint), [swiftformat](https://github.com/nicklockwood/SwiftFormat) |
|
||||||
| Tcl | [nagelfar](http://nagelfar.sourceforge.net) !! |
|
| Tcl | [nagelfar](http://nagelfar.sourceforge.net) !! |
|
||||||
| Terraform | [tflint](https://github.com/wata727/tflint) |
|
| Terraform | [tflint](https://github.com/wata727/tflint) |
|
||||||
|
|||||||
@@ -195,6 +195,11 @@ let s:default_registry = {
|
|||||||
\ 'suggested_filetypes': ['sh'],
|
\ 'suggested_filetypes': ['sh'],
|
||||||
\ 'description': 'Fix sh files with shfmt.',
|
\ 'description': 'Fix sh files with shfmt.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'sqlfmt': {
|
||||||
|
\ 'function': 'ale#fixers#sqlfmt#Fix',
|
||||||
|
\ 'suggested_filetypes': ['sql'],
|
||||||
|
\ 'description': 'Fix SQL files with sqlfmt.',
|
||||||
|
\ },
|
||||||
\ 'google_java_format': {
|
\ 'google_java_format': {
|
||||||
\ 'function': 'ale#fixers#google_java_format#Fix',
|
\ 'function': 'ale#fixers#google_java_format#Fix',
|
||||||
\ 'suggested_filetypes': ['java'],
|
\ 'suggested_filetypes': ['java'],
|
||||||
|
|||||||
13
autoload/ale/fixers/sqlfmt.vim
Normal file
13
autoload/ale/fixers/sqlfmt.vim
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
call ale#Set('sql_sqlfmt_executable', 'sqlfmt')
|
||||||
|
call ale#Set('sql_sqlfmt_options', '')
|
||||||
|
|
||||||
|
function! ale#fixers#sqlfmt#Fix(buffer) abort
|
||||||
|
let l:executable = ale#Var(a:buffer, 'sql_sqlfmt_executable')
|
||||||
|
let l:options = ale#Var(a:buffer, 'sql_sqlfmt_options')
|
||||||
|
|
||||||
|
return {
|
||||||
|
\ 'command': ale#Escape(l:executable)
|
||||||
|
\ . ' -w'
|
||||||
|
\ . (empty(l:options) ? '' : ' ' . l:options),
|
||||||
|
\}
|
||||||
|
endfunction
|
||||||
25
doc/ale-sql.txt
Normal file
25
doc/ale-sql.txt
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
===============================================================================
|
||||||
|
ALE SQL Integration *ale-sql-options*
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
sqlfmt *ale-sql-sqlfmt*
|
||||||
|
|
||||||
|
g:ale_sql_sqlfmt_executable *g:ale_sql_sqlfmt_executable*
|
||||||
|
*b:ale_sql_sqlfmt_executable*
|
||||||
|
Type: |String|
|
||||||
|
Default: `'sqlfmt'`
|
||||||
|
|
||||||
|
This variable sets executable used for sqlfmt.
|
||||||
|
|
||||||
|
g:ale_sql_sqlfmt_options *g:ale_sql_sqlfmt_options*
|
||||||
|
*b:ale_sql_sqlfmt_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be set to pass additional options to the sqlfmt fixer.
|
||||||
|
At this time only the -u flag is available to format with upper-case.
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
@@ -269,6 +269,8 @@ CONTENTS *ale-contents*
|
|||||||
solium..............................|ale-solidity-solium|
|
solium..............................|ale-solidity-solium|
|
||||||
spec..................................|ale-spec-options|
|
spec..................................|ale-spec-options|
|
||||||
rpmlint.............................|ale-spec-rpmlint|
|
rpmlint.............................|ale-spec-rpmlint|
|
||||||
|
sql...................................|ale-sql-options|
|
||||||
|
sqlfmt..............................|ale-sql-sqlfmt|
|
||||||
stylus................................|ale-stylus-options|
|
stylus................................|ale-stylus-options|
|
||||||
stylelint...........................|ale-stylus-stylelint|
|
stylelint...........................|ale-stylus-stylelint|
|
||||||
tcl...................................|ale-tcl-options|
|
tcl...................................|ale-tcl-options|
|
||||||
@@ -438,7 +440,7 @@ Notes:
|
|||||||
* SML: `smlnj`
|
* SML: `smlnj`
|
||||||
* Solidity: `solhint`, `solium`
|
* Solidity: `solhint`, `solium`
|
||||||
* Stylus: `stylelint`
|
* Stylus: `stylelint`
|
||||||
* SQL: `sqlint`
|
* SQL: `sqlint`, `sqlfmt`
|
||||||
* Swift: `swiftlint`, `swiftformat`
|
* Swift: `swiftlint`, `swiftformat`
|
||||||
* Tcl: `nagelfar`!!
|
* Tcl: `nagelfar`!!
|
||||||
* Terraform: `tflint`
|
* Terraform: `tflint`
|
||||||
|
|||||||
26
test/fixers/test_sqlfmt_fixer_callback.vader
Normal file
26
test/fixers/test_sqlfmt_fixer_callback.vader
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
Before:
|
||||||
|
Save g:ale_sql_sqlfmt_executable
|
||||||
|
Save g:ale_sql_sqlfmt_options
|
||||||
|
|
||||||
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
|
Execute(The sqlfmt callback should return the correct default values):
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('sqlfmt')
|
||||||
|
\ . ' -w',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#sqlfmt#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The sqlfmt executable and options should be configurable):
|
||||||
|
let g:ale_sql_sqlfmt_executable = '/path/to/sqlfmt'
|
||||||
|
let g:ale_sql_sqlfmt_options = '-u'
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape('/path/to/sqlfmt')
|
||||||
|
\ . ' -w'
|
||||||
|
\ . ' -u',
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#sqlfmt#Fix(bufnr(''))
|
||||||
Reference in New Issue
Block a user