commit
ca0cdd26fc
@ -305,6 +305,11 @@ let s:default_registry = {
|
||||
\ 'suggested_filetypes': ['tex'],
|
||||
\ 'description' : 'Indent code within environments, commands, after headings and within special code blocks.',
|
||||
\ },
|
||||
\ 'pgformatter': {
|
||||
\ 'function': 'ale#fixers#pgformatter#Fix',
|
||||
\ 'suggested_filetypes': ['sql'],
|
||||
\ 'description': 'A PostgreSQL SQL syntax beautifier',
|
||||
\ },
|
||||
\}
|
||||
|
||||
" Reset the function registry to the default entries.
|
||||
|
12
autoload/ale/fixers/pgformatter.vim
Normal file
12
autoload/ale/fixers/pgformatter.vim
Normal file
@ -0,0 +1,12 @@
|
||||
call ale#Set('sql_pgformatter_executable', 'pg_format')
|
||||
call ale#Set('sql_pgformatter_options', '')
|
||||
|
||||
function! ale#fixers#pgformatter#Fix(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'sql_pgformatter_executable')
|
||||
let l:options = ale#Var(a:buffer, 'sql_pgformatter_options')
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . (empty(l:options) ? '' : ' ' . l:options),
|
||||
\}
|
||||
endfunction
|
@ -2,6 +2,24 @@
|
||||
ALE SQL Integration *ale-sql-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
pgformatter *ale-sql-pgformatter*
|
||||
|
||||
g:ale_sql_pgformatter_executable *g:ale_sql_pgformatter_executable*
|
||||
*b:ale_sql_pgformatter_executable*
|
||||
Type: |String|
|
||||
Default: `'pg_format'`
|
||||
|
||||
This variable sets executable used for pgformatter.
|
||||
|
||||
g:ale_sql_pgformatter_options *g:ale_sql_pgformatter_options*
|
||||
*b:ale_sql_pgformatter_options*
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be set to pass additional options to the pgformatter fixer.
|
||||
|
||||
|
||||
===============================================================================
|
||||
sqlfmt *ale-sql-sqlfmt*
|
||||
|
||||
|
@ -415,6 +415,7 @@ Notes:
|
||||
* `solhint`
|
||||
* `solium`
|
||||
* SQL
|
||||
* `pgformatter`
|
||||
* `sqlfmt`
|
||||
* `sqlint`
|
||||
* Stylus
|
||||
|
@ -2236,6 +2236,7 @@ documented in additional help files.
|
||||
spec....................................|ale-spec-options|
|
||||
rpmlint...............................|ale-spec-rpmlint|
|
||||
sql.....................................|ale-sql-options|
|
||||
pgformatter...........................|ale-sql-pgformatter|
|
||||
sqlfmt................................|ale-sql-sqlfmt|
|
||||
stylus..................................|ale-stylus-options|
|
||||
stylelint.............................|ale-stylus-stylelint|
|
||||
|
@ -424,6 +424,7 @@ formatting.
|
||||
* [solhint](https://github.com/protofire/solhint)
|
||||
* [solium](https://github.com/duaraghav8/Solium)
|
||||
* SQL
|
||||
* [pgformatter](https://github.com/darold/pgFormatter)
|
||||
* [sqlfmt](https://github.com/jackc/sqlfmt)
|
||||
* [sqlint](https://github.com/purcell/sqlint)
|
||||
* Stylus
|
||||
|
24
test/fixers/test_pgformatter_fixer_callback.vader
Normal file
24
test/fixers/test_pgformatter_fixer_callback.vader
Normal file
@ -0,0 +1,24 @@
|
||||
Before:
|
||||
Save g:ale_sql_pgformatter_executable
|
||||
Save g:ale_sql_pgformatter_options
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
Execute(The pgFormatter callback should return the correct default values):
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('pg_format')
|
||||
\ },
|
||||
\ ale#fixers#pgformatter#Fix(bufnr(''))
|
||||
|
||||
Execute(The pgFormatter executable and options should be configurable):
|
||||
let g:ale_sql_pgformatter_executable = '/path/to/pg_format'
|
||||
let g:ale_sql_pgformatter_options = '-n'
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('/path/to/pg_format')
|
||||
\ . ' -n',
|
||||
\ },
|
||||
\ ale#fixers#pgformatter#Fix(bufnr(''))
|
Loading…
Reference in New Issue
Block a user