]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/ale_linters/tex/lacheck.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 / tex / lacheck.vim
diff --git a/.vim/bundle/ale/ale_linters/tex/lacheck.vim b/.vim/bundle/ale/ale_linters/tex/lacheck.vim
new file mode 100644 (file)
index 0000000..35aad08
--- /dev/null
@@ -0,0 +1,43 @@
+" Author: Andrew Balmos - <andrew@balmos.org>
+" Description: lacheck for LaTeX files
+
+call ale#Set('tex_lacheck_executable', 'lacheck')
+
+function! ale_linters#tex#lacheck#Handle(buffer, lines) abort
+    " Mattes lines like:
+    "
+    " "book.tex", line 37: possible unwanted space at "{"
+    " "book.tex", line 38: missing `\ ' after "etc."
+    let l:pattern = '^"\(.\+\)", line \(\d\+\): \(.\+\)$'
+    let l:output = []
+
+    for l:match in ale#util#GetMatches(a:lines, l:pattern)
+        " lacheck follows `\input{}` commands. If the cwd is not the same as the
+        " file in the buffer then it will fail to find the inputted items. We do not
+        " want warnings from those items anyway
+        if !empty(matchstr(l:match[3], '^Could not open ".\+"$'))
+            continue
+        endif
+
+        " lacheck follows `\input{}` commands. We are only interested in
+        " reporting errors for the current buffer only.
+        if empty(matchstr(fnamemodify(l:match[1], ':t'), fnamemodify(bufname(a:buffer), ':t')))
+            continue
+        endif
+
+        call add(l:output, {
+        \   'lnum': l:match[2] + 0,
+        \   'text': l:match[3],
+        \   'type': 'W',
+        \})
+    endfor
+
+    return l:output
+endfunction
+
+call ale#linter#Define('tex', {
+\   'name': 'lacheck',
+\   'executable': {b -> ale#Var(b, 'tex_lacheck_executable')},
+\   'command': '%e %t',
+\   'callback': 'ale_linters#tex#lacheck#Handle'
+\})