luac.vim 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. "============================================================================
  2. "File: lua.vim
  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.
  10. "
  11. "============================================================================
  12. if exists('g:loaded_syntastic_lua_luac_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_lua_luac_checker = 1
  16. let s:save_cpo = &cpo
  17. set cpo&vim
  18. function! SyntaxCheckers_lua_luac_GetHighlightRegex(pos)
  19. let result = ''
  20. let near = matchstr(a:pos['text'], '\mnear ''\zs[^'']\+\ze''')
  21. if near !=# ''
  22. if near ==# '<eof>'
  23. let p = getpos('$')
  24. let a:pos['lnum'] = p[1]
  25. let a:pos['col'] = p[2]
  26. let result = '\%' . p[2] . 'c'
  27. else
  28. let result = '\V' . escape(near, '\')
  29. endif
  30. " XXX the following piece of code is evil, and is likely to break
  31. " in future versions of syntastic; enable it at your own risk :)
  32. "let open = matchstr(a:pos['text'], '\m(to close ''\zs[^'']\+\ze'' at line [0-9]\+)')
  33. "if open != ''
  34. " let line = str2nr(matchstr(a:pos['text'], '\m(to close ''[^'']\+'' at line \zs[0-9]\+\ze)'))
  35. " let group = a:pos['type'] ==? 'E' ? 'SyntasticError' : 'SyntasticWarning'
  36. " call matchadd(group, '\%' . line . 'l\V' . escape(open, '\'))
  37. "endif
  38. endif
  39. return result
  40. endfunction
  41. function! SyntaxCheckers_lua_luac_GetLocList() dict
  42. let makeprg = self.makeprgBuild({ 'args_after': '-p' })
  43. let errorformat = '%*\f: %#%f:%l: %m'
  44. return SyntasticMake({
  45. \ 'makeprg': makeprg,
  46. \ 'errorformat': errorformat,
  47. \ 'defaults': { 'bufnr': bufnr(''), 'type': 'E' } })
  48. endfunction
  49. call g:SyntasticRegistry.CreateAndRegisterChecker({
  50. \ 'filetype': 'lua',
  51. \ 'name': 'luac'})
  52. let &cpo = s:save_cpo
  53. unlet s:save_cpo
  54. " vim: set sw=4 sts=4 et fdm=marker: