]> git.madduck.net Git - etc/vim.git/blob - ale_linters/sql/sqllint.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / ale_linters / sql / sqllint.vim
1 " ale_linters/sql/sqllint.vim
2 " Author: Joe Reynolds <joereynolds952@gmail.co>
3 " Description: sql-lint for SQL files.
4 "              sql-lint can be found at
5 "              https://www.npmjs.com/package/sql-lint
6 "              https://github.com/joereynolds/sql-lint
7
8 function! ale_linters#sql#sqllint#Handle(buffer, lines) abort
9     " Matches patterns like the following:
10     "
11     " stdin:1 [ER_NO_DB_ERROR] No database selected
12     let l:pattern = '\v^[^:]+:(\d+) (.*)'
13     let l:output = []
14
15     for l:match in ale#util#GetMatches(a:lines, l:pattern)
16         call add(l:output, {
17         \   'lnum': l:match[1] + 0,
18         \   'col': l:match[2] + 0,
19         \   'type': l:match[3][0],
20         \   'text': l:match[0],
21         \})
22     endfor
23
24     return l:output
25 endfunction
26
27 call ale#linter#Define('sql', {
28 \   'name': 'sqllint',
29 \   'aliases': ['sql-lint'],
30 \   'executable': 'sql-lint',
31 \   'command': 'sql-lint',
32 \   'callback': 'ale_linters#sql#sqllint#Handle',
33 \})