Skip to content

Instantly share code, notes, and snippets.

@kizzx2
Created March 7, 2018 08:17
Show Gist options
  • Save kizzx2/4f3b797f443dbfa2453a3585fbed47c7 to your computer and use it in GitHub Desktop.
Save kizzx2/4f3b797f443dbfa2453a3585fbed47c7 to your computer and use it in GitHub Desktop.
ALE Linter for commitlint
function! ale_linters#gitcommit#commitlint#Handle(buffer, lines) abort
" Matches patterns line the following:
let l:pattern = '^\(✖\|⚠\)\s\+\(.*\) \(\[.*\]\)$'
let l:output = []
let l:line = getline(1)
if l:line[0] != '#'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:item = {
\ 'lnum': 1,
\ 'text': l:match[2],
\ 'code': l:match[3],
\ 'type': l:match[1] is# '✖' ? 'E' : 'W',
\}
call add(l:output, l:item)
endfor
endif
return l:output
endfunction
call ale#linter#Define("gitcommit", {
\ 'name': 'commitlint',
\ 'executable': 'commitlint',
\ 'command': 'commitlint -c false',
\ 'output_stream': 'stdout',
\ 'callback': 'ale_linters#gitcommit#commitlint#Handle',
\ })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment