2016-10-24 15:32:52 -04:00
|
|
|
" Author: awlayton <alex@layton.in>
|
|
|
|
" Description: mlint for MATLAB files
|
|
|
|
|
|
|
|
let g:ale_matlab_mlint_executable =
|
|
|
|
\ get(g:, 'ale_matlab_mlint_executable', 'mlint')
|
|
|
|
|
2017-02-11 14:40:57 -05:00
|
|
|
function! ale_linters#matlab#mlint#GetExecutable(buffer) abort
|
2017-04-15 20:24:08 -04:00
|
|
|
return ale#Var(a:buffer, 'matlab_mlint_executable')
|
2017-02-11 14:40:57 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#matlab#mlint#GetCommand(buffer) abort
|
|
|
|
let l:executable = ale_linters#matlab#mlint#GetExecutable(a:buffer)
|
|
|
|
|
|
|
|
return l:executable . ' -id %t'
|
|
|
|
endfunction
|
|
|
|
|
2017-01-22 09:54:57 -05:00
|
|
|
function! ale_linters#matlab#mlint#Handle(buffer, lines) abort
|
2016-10-24 15:32:52 -04:00
|
|
|
" 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 = []
|
|
|
|
|
2017-04-17 19:35:53 -04:00
|
|
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
2016-10-24 15:32:52 -04:00
|
|
|
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
|
2017-08-08 03:39:13 -04:00
|
|
|
if l:code is# 'FNDEF'
|
2016-10-24 15:32:52 -04:00
|
|
|
continue
|
|
|
|
endif
|
|
|
|
|
|
|
|
call add(l:output, {
|
|
|
|
\ 'bufnr': a:buffer,
|
|
|
|
\ 'lnum': l:lnum,
|
|
|
|
\ 'col': l:col,
|
|
|
|
\ 'text': l:text,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\})
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('matlab', {
|
|
|
|
\ 'name': 'mlint',
|
2017-02-11 14:40:57 -05:00
|
|
|
\ 'executable_callback': 'ale_linters#matlab#mlint#GetExecutable',
|
|
|
|
\ 'command_callback': 'ale_linters#matlab#mlint#GetCommand',
|
2016-10-24 15:32:52 -04:00
|
|
|
\ 'output_stream': 'stderr',
|
|
|
|
\ 'callback': 'ale_linters#matlab#mlint#Handle',
|
|
|
|
\})
|