From c89c4fcef9379ec44ed5e0ec74c9f384ad4f001d Mon Sep 17 00:00:00 2001 From: w0rp Date: Mon, 3 Oct 2016 13:18:27 +0100 Subject: Add support for shellcheck linting. --- plugin/ale/handlers.vim | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 plugin/ale/handlers.vim (limited to 'plugin') diff --git a/plugin/ale/handlers.vim b/plugin/ale/handlers.vim new file mode 100644 index 00000000..6777ac42 --- /dev/null +++ b/plugin/ale/handlers.vim @@ -0,0 +1,40 @@ +" Author: w0rp +" Description: This file defines some standard error format handlers. Any +" linter which outputs warnings and errors in a format accepted by one of +" these functions can simply use one of these pre-defined error handlers. + +if exists('g:loaded_ale_handlers') + finish +endif + +let g:loaded_ale_handlers = 1 + +function! ale#handlers#HandleGCCFormat(buffer, lines) + " Look for lines like the following. + " + " :8:5: warning: conversion lacks type at end of format [-Wformat=] + " :10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’) + " -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004] + let pattern = '^[^:]\+:\(\d\+\):\(\d\+\): \([^:]\+\): \(.\+\)$' + let output = [] + + for line in a:lines + let l:match = matchlist(line, pattern) + + if len(l:match) == 0 + continue + endif + + call add(output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'vcol': 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': l:match[3] ==# 'error' ? 'E' : 'W', + \ 'nr': -1, + \}) + endfor + + return output +endfunction -- cgit v1.2.3