summaryrefslogtreecommitdiff
path: root/ale_linters/matlab
diff options
context:
space:
mode:
authorAlex Layton <alex@layton.in>2016-10-24 15:32:52 -0400
committerw0rp <w0rp@users.noreply.github.com>2016-10-24 20:32:52 +0100
commit95373ddab5966e5975c7d1a9f52ddbbeeb664cc0 (patch)
tree32598c7230f4026be0feb988bb31984489863a5b /ale_linters/matlab
parent6e66b60b63f3b9504bce621dd460de57007ace49 (diff)
downloadale-95373ddab5966e5975c7d1a9f52ddbbeeb664cc0.zip
Add support for mlint, a MATLAB linter (#145)
* Add support for mlint, a MATLAB linter * Fix mlint linter as requested * Clean up leftover loaded flag for mlint
Diffstat (limited to 'ale_linters/matlab')
-rw-r--r--ale_linters/matlab/mlint.vim55
1 files changed, 55 insertions, 0 deletions
diff --git a/ale_linters/matlab/mlint.vim b/ale_linters/matlab/mlint.vim
new file mode 100644
index 00000000..e1e6cf05
--- /dev/null
+++ b/ale_linters/matlab/mlint.vim
@@ -0,0 +1,55 @@
+" Author: awlayton <alex@layton.in>
+" Description: mlint for MATLAB files
+
+let g:ale_matlab_mlint_executable =
+\ get(g:, 'ale_matlab_mlint_executable', 'mlint')
+
+function! ale_linters#matlab#mlint#Handle(buffer, lines)
+ " Matches patterns like the following:
+ "
+ " L 27 (C 1): FNDEF: Terminate statement with semicolon to suppress output.
+ " L 30 (C 13-15): FNDEF: A quoted string is unterminated.
+ let l:pattern = '^L \(\d\+\) (C \([0-9-]\+\)): \([A-Z]\+\): \(.\+\)$'
+ let l:output = []
+
+ for l:line in a:lines
+ let l:match = matchlist(l:line, l:pattern)
+
+ if len(l:match) == 0
+ continue
+ endif
+
+ let l:lnum = l:match[1] + 0
+ let l:col = l:match[2] + 0
+ let l:code = l:match[3]
+ let l:text = l:match[4]
+
+ " Suppress erroneous waring about filename
+ " TODO: Enable this error when copying filename is supported
+ if l:code ==# 'FNDEF'
+ continue
+ endif
+
+ " vcol is needed to indicate that the column is a character.
+ call add(l:output, {
+ \ 'bufnr': a:buffer,
+ \ 'lnum': l:lnum,
+ \ 'vcol': 0,
+ \ 'col': l:col,
+ \ 'text': l:text,
+ \ 'type': 'W',
+ \ 'nr': -1,
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('matlab', {
+\ 'name': 'mlint',
+\ 'executable': 'mlint',
+\ 'command': g:ale#util#stdin_wrapper .
+\ ' .m ' . g:ale_matlab_mlint_executable . ' -id',
+\ 'output_stream': 'stderr',
+\ 'callback': 'ale_linters#matlab#mlint#Handle',
+\})