]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/ale_linters/matlab/mlint.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / matlab / mlint.vim
diff --git a/.vim/bundle/ale/ale_linters/matlab/mlint.vim b/.vim/bundle/ale/ale_linters/matlab/mlint.vim
new file mode 100644 (file)
index 0000000..e7daf37
--- /dev/null
@@ -0,0 +1,44 @@
+" Author: awlayton <alex@layton.in>
+" Description: mlint for MATLAB files
+
+call ale#Set('matlab_mlint_executable', 'mlint')
+
+function! ale_linters#matlab#mlint#Handle(buffer, lines) abort
+    " 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:match in ale#util#GetMatches(a:lines, l:pattern)
+        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 warning about filename
+        " TODO: Enable this error when copying filename is supported
+        if l:code is# 'FNDEF'
+            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',
+\   'executable': {b -> ale#Var(b, 'matlab_mlint_executable')},
+\   'command': '%e -id %t',
+\   'output_stream': 'stderr',
+\   'callback': 'ale_linters#matlab#mlint#Handle',
+\})