summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2016-10-03 13:18:27 +0100
committerw0rp <devw0rp@gmail.com>2016-10-03 13:18:27 +0100
commitc89c4fcef9379ec44ed5e0ec74c9f384ad4f001d (patch)
treed18fa8274f4303622254a7b90f158bb3046a0e1a /plugin
parent23383ce547c34482cec1860279f5f4af3c0f8217 (diff)
downloadale-c89c4fcef9379ec44ed5e0ec74c9f384ad4f001d.zip
Add support for shellcheck linting.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/ale/handlers.vim40
1 files changed, 40 insertions, 0 deletions
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 <devw0rp@gmail.com>
+" 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.
+ "
+ " <stdin>:8:5: warning: conversion lacks type at end of format [-Wformat=]
+ " <stdin>: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