summaryrefslogtreecommitdiff
path: root/ale_linters/sql
diff options
context:
space:
mode:
authorAdriaan Zonnenberg <adriaanzon@users.noreply.github.com>2017-04-15 12:24:05 +0200
committerw0rp <w0rp@users.noreply.github.com>2017-04-15 11:24:05 +0100
commit8351bdbc066ed7f56bf78f4286565652e4a207ed (patch)
tree73ff2ae73674e452848476b96509fd1b032c2ba3 /ale_linters/sql
parent349b31104a500e1e0376ec0b2022d8c478d0bf24 (diff)
downloadale-8351bdbc066ed7f56bf78f4286565652e4a207ed.zip
Add SQL linter sqlint, closes #395 (#472)
Diffstat (limited to 'ale_linters/sql')
-rw-r--r--ale_linters/sql/sqlint.vim34
1 files changed, 34 insertions, 0 deletions
diff --git a/ale_linters/sql/sqlint.vim b/ale_linters/sql/sqlint.vim
new file mode 100644
index 00000000..d8bf9dce
--- /dev/null
+++ b/ale_linters/sql/sqlint.vim
@@ -0,0 +1,34 @@
+" Author: Adriaan Zonnenberg <amz@adriaan.xyz>
+" Description: sqlint for SQL files
+
+function! ale_linters#sql#sqlint#Handle(buffer, lines) abort
+ " Matches patterns like the following:
+ "
+ " stdin:3:1:ERROR syntax error at or near "WIBBLE"
+ let l:pattern = '\v^[^:]+:(\d+):(\d+):(\u+) (.*)'
+ let l:output = []
+
+ for l:line in a:lines
+ let l:match = matchlist(l:line, l:pattern)
+
+ if empty(l:match)
+ continue
+ endif
+
+ call add(l:output, {
+ \ 'lnum': l:match[1] + 0,
+ \ 'col': l:match[2] + 0,
+ \ 'type': l:match[3][0],
+ \ 'text': l:match[4],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('sql', {
+\ 'name': 'sqlint',
+\ 'executable': 'sqlint',
+\ 'command': 'sqlint',
+\ 'callback': 'ale_linters#sql#sqlint#Handle',
+\})