File: sqlint.vim

package info (click to toggle)
vim-ale 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,764 kB
  • sloc: sh: 499; python: 311; perl: 31; makefile: 4; xml: 4; javascript: 1
file content (28 lines) | stat: -rw-r--r-- 769 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
" 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:match in ale#util#GetMatches(a:lines, l:pattern)
        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',
\})