summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-09-09 11:55:42 +0100
committerGitHub <noreply@github.com>2018-09-09 11:55:42 +0100
commit0948dcc435201f0ea62a22c53ce31971a75cba35 (patch)
treeb63ae0f4a50b62703823b56bf63987747046748e /autoload
parent395aba19c37a4bc4ead34f115381227d7b71bc0a (diff)
parenta97ef49c5174f5d60f2dc68718d96965361f3d4e (diff)
downloadale-0948dcc435201f0ea62a22c53ce31971a75cba35.zip
Merge pull request #1897 from LEI/add-sqlfmt-fixer
Add support for sqlfmt
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/sqlfmt.vim13
2 files changed, 18 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 0a54f49e..eb12f22d 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -195,6 +195,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['sh'],
\ 'description': 'Fix sh files with shfmt.',
\ },
+\ 'sqlfmt': {
+\ 'function': 'ale#fixers#sqlfmt#Fix',
+\ 'suggested_filetypes': ['sql'],
+\ 'description': 'Fix SQL files with sqlfmt.',
+\ },
\ 'google_java_format': {
\ 'function': 'ale#fixers#google_java_format#Fix',
\ 'suggested_filetypes': ['java'],
diff --git a/autoload/ale/fixers/sqlfmt.vim b/autoload/ale/fixers/sqlfmt.vim
new file mode 100644
index 00000000..c88a8ec2
--- /dev/null
+++ b/autoload/ale/fixers/sqlfmt.vim
@@ -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