]> git.madduck.net Git - etc/vim.git/blob - ale_linters/lua/luac.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 / lua / luac.vim
1 " Author: Jon Xie https://github.com/xiejiangzhi
2 " Description: luac linter for lua files
3
4 call ale#Set('lua_luac_executable', 'luac')
5
6 function! ale_linters#lua#luac#Handle(buffer, lines) abort
7     " Matches patterns line the following:
8     "
9     " luac: stdin:5: '=' expected near ')'
10     " luac: stdin:8: ')' expected (to close '(' at line 6) near '123'
11     let l:pattern = '\v^.*:(\d+): (.+)$'
12     let l:output = []
13
14     for l:match in ale#util#GetMatches(a:lines, l:pattern)
15         call add(l:output, {
16         \   'lnum': l:match[1] + 0,
17         \   'type': 'E',
18         \   'text': l:match[2],
19         \})
20     endfor
21
22     return l:output
23 endfunction
24
25 call ale#linter#Define('lua', {
26 \   'name': 'luac',
27 \   'executable': {b -> ale#Var(b, 'lua_luac_executable')},
28 \   'command': '%e -p -',
29 \   'output_stream': 'stderr',
30 \   'callback': 'ale_linters#lua#luac#Handle',
31 \})