]> git.madduck.net Git - etc/vim.git/blob - 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:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / ale_linters / tex / lacheck.vim
1 " Author: Andrew Balmos - <andrew@balmos.org>
2 " Description: lacheck for LaTeX files
3
4 call ale#Set('tex_lacheck_executable', 'lacheck')
5
6 function! ale_linters#tex#lacheck#Handle(buffer, lines) abort
7     " Mattes lines like:
8     "
9     " "book.tex", line 37: possible unwanted space at "{"
10     " "book.tex", line 38: missing `\ ' after "etc."
11     let l:pattern = '^"\(.\+\)", line \(\d\+\): \(.\+\)$'
12     let l:output = []
13
14     for l:match in ale#util#GetMatches(a:lines, l:pattern)
15         " lacheck follows `\input{}` commands. If the cwd is not the same as the
16         " file in the buffer then it will fail to find the inputted items. We do not
17         " want warnings from those items anyway
18         if !empty(matchstr(l:match[3], '^Could not open ".\+"$'))
19             continue
20         endif
21
22         " lacheck follows `\input{}` commands. We are only interested in
23         " reporting errors for the current buffer only.
24         if empty(matchstr(fnamemodify(l:match[1], ':t'), fnamemodify(bufname(a:buffer), ':t')))
25             continue
26         endif
27
28         call add(l:output, {
29         \   'lnum': l:match[2] + 0,
30         \   'text': l:match[3],
31         \   'type': 'W',
32         \})
33     endfor
34
35     return l:output
36 endfunction
37
38 call ale#linter#Define('tex', {
39 \   'name': 'lacheck',
40 \   'executable': {b -> ale#Var(b, 'tex_lacheck_executable')},
41 \   'command': '%e %t',
42 \   'callback': 'ale_linters#tex#lacheck#Handle'
43 \})