1 "============================================================================
3 "Description: Syntax checking plugin for syntastic.vim
4 "Maintainer: Gregor Uhlenheuer <kongo2002 at gmail dot com>
5 "License: This program is free software. It comes without any warranty,
6 " to the extent permitted by applicable law. You can redistribute
7 " it and/or modify it under the terms of the Do What The Fuck You
8 " Want To Public License, Version 2, as published by Sam Hocevar.
9 " See http://sam.zoy.org/wtfpl/COPYING for more details.
11 "============================================================================
13 if exists('loaded_lua_syntax_checker')
16 let loaded_lua_syntax_checker = 1
18 " check if the lua compiler is installed
19 if !executable('luac')
23 function! SyntaxCheckers_lua_Term(pos)
24 let near = matchstr(a:pos['text'], "near '[^']\\+'")
27 let near = split(near, "'")[1]
30 let a:pos['lnum'] = p[1]
31 let a:pos['col'] = p[2]
32 let result = '\%'.p[2].'c'
34 let result = '\V'.near
36 let open = matchstr(a:pos['text'], "(to close '[^']\\+' at line [0-9]\\+)")
38 let oline = split(open, "'")[1:2]
39 let line = 0+strpart(oline[1], 9)
40 call matchadd('SpellCap', '\%'.line.'l\V'.oline[0])
46 function! SyntaxCheckers_lua_GetLocList()
47 let makeprg = 'luac -p ' . shellescape(expand('%'))
48 let errorformat = 'luac: %#%f:%l: %m'
50 let loclist = SyntasticMake({ 'makeprg': makeprg,
51 \ 'errorformat': errorformat,
52 \ 'defaults': { 'bufnr': bufnr(''), 'type': 'E' } })
54 call SyntasticHighlightErrors(loclist, function("SyntaxCheckers_lua_Term"))