mirror of https://github.com/dense-analysis/ale
parent
3e8c8d3ccb
commit
a6c59faa0f
|
@ -260,6 +260,11 @@ let s:default_registry = {
|
|||
\ 'suggested_filetypes': ['sql'],
|
||||
\ 'description': 'Fix SQL files with sqlfmt.',
|
||||
\ },
|
||||
\ 'sqlformat': {
|
||||
\ 'function': 'ale#fixers#sqlformat#Fix',
|
||||
\ 'suggested_filetypes': ['sql'],
|
||||
\ 'description': 'Fix SQL files with sqlformat.',
|
||||
\ },
|
||||
\ 'google_java_format': {
|
||||
\ 'function': 'ale#fixers#google_java_format#Fix',
|
||||
\ 'suggested_filetypes': ['java'],
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
" Author: Cluas <Cluas@live.cn>
|
||||
" Description: Fixing files with sqlformat.
|
||||
|
||||
call ale#Set('sql_sqlformat_executable', 'sqlformat')
|
||||
call ale#Set('sql_sqlformat_options', '')
|
||||
|
||||
function! ale#fixers#sqlformat#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'sql_sqlformat_executable')
|
||||
let l:options = ale#Var(a:buffer, 'sql_sqlformat_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -'
|
||||
\}
|
||||
endfunction
|
|
@ -39,5 +39,23 @@ g:ale_sql_sqlfmt_options *g:ale_sql_sqlfmt_options*
|
|||
At this time only the -u flag is available to format with upper-case.
|
||||
|
||||
|
||||
===============================================================================
|
||||
sqlformat *ale-sql-sqlformat*
|
||||
|
||||
g:ale_sql_sqlformat_executable *g:ale_sql_sqlformat_executable*
|
||||
*b:ale_sql_sqlformat_executable*
|
||||
Type: |String|
|
||||
Default: `'sqlformat'`
|
||||
|
||||
This variable sets executable used for sqlformat.
|
||||
|
||||
g:ale_sql_sqlformat_options *g:ale_sql_sqlformat_options*
|
||||
*b:ale_sql_sqlformat_options*
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be set to pass additional options to the sqlformat fixer.
|
||||
|
||||
|
||||
===============================================================================
|
||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||
|
|
|
@ -426,6 +426,7 @@ Notes:
|
|||
* SQL
|
||||
* `pgformatter`
|
||||
* `sqlfmt`
|
||||
* `sqlformat`
|
||||
* `sqlint`
|
||||
* Stylus
|
||||
* `stylelint`
|
||||
|
|
|
@ -2377,6 +2377,7 @@ documented in additional help files.
|
|||
sql.....................................|ale-sql-options|
|
||||
pgformatter...........................|ale-sql-pgformatter|
|
||||
sqlfmt................................|ale-sql-sqlfmt|
|
||||
sqlformat.............................|ale-sql-sqlformat|
|
||||
stylus..................................|ale-stylus-options|
|
||||
stylelint.............................|ale-stylus-stylelint|
|
||||
sugarss.................................|ale-sugarss-options|
|
||||
|
|
|
@ -435,6 +435,7 @@ formatting.
|
|||
* SQL
|
||||
* [pgformatter](https://github.com/darold/pgFormatter)
|
||||
* [sqlfmt](https://github.com/jackc/sqlfmt)
|
||||
* [sqlformat](https://github.com/andialbrecht/sqlparse)
|
||||
* [sqlint](https://github.com/purcell/sqlint)
|
||||
* Stylus
|
||||
* [stylelint](https://github.com/stylelint/stylelint)
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
Before:
|
||||
Save g:ale_sql_sqlformat_executable
|
||||
Save g:ale_sql_sqlformat_options
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
Execute(The sqlformat callback should return the correct default values):
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('sqlformat') . ' -'
|
||||
\ },
|
||||
\ ale#fixers#sqlformat#Fix(bufnr(''))
|
||||
|
||||
Execute(The sqlformat executable and options should be configurable):
|
||||
let g:ale_sql_sqlformat_executable = '/path/to/sqlformat'
|
||||
let g:ale_sql_sqlformat_options = '-a'
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('/path/to/sqlformat')
|
||||
\ . ' -a -'
|
||||
\ },
|
||||
\ ale#fixers#sqlformat#Fix(bufnr(''))
|
Loading…
Reference in New Issue