cgc.vim 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. "============================================================================
  2. "File: glsl.vim
  3. "Description: Syntax checker for OpenGL Shading Language
  4. "Maintainer: Joshua Rahm <joshuarahm@gmail.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_glsl_cgc_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_glsl_cgc_checker = 1
  16. let s:glsl_extensions = {
  17. \ 'glslf': 'gpu_fp',
  18. \ 'glslv': 'gpu_vp',
  19. \ 'frag': 'gpu_fp',
  20. \ 'vert': 'gpu_vp',
  21. \ 'fp': 'gpu_fp',
  22. \ 'vp': 'gpu_vp'
  23. \ }
  24. let s:save_cpo = &cpo
  25. set cpo&vim
  26. function! SyntaxCheckers_glsl_cgc_GetLocList() dict " {{{1
  27. let buf = bufnr('')
  28. let makeprg = self.makeprgBuild({
  29. \ 'args_before': '-oglsl -profile ' . s:GetProfile(buf),
  30. \ 'args': (exists('g:syntastic_glsl_options') ? ' ' . g:syntastic_glsl_options : '') })
  31. let errorformat =
  32. \ '%E%f(%l) : error %m,' .
  33. \ '%W%f(%l) : warning %m'
  34. return SyntasticMake({
  35. \ 'makeprg': makeprg,
  36. \ 'errorformat': errorformat })
  37. endfunction " }}}1
  38. " Utilities {{{1
  39. function! s:GetProfile(buf) " {{{2
  40. let profile = matchstr(get(filter(getbufline(a:buf, 1, 100), 'v:val =~# "\\m\\C^//\\s*profile:"'), 0, ''), '\m\C^//\s*profile:\s*\zs.*')
  41. if profile ==# ''
  42. let extensions = syntastic#util#bufVar(a:buf, 'glsl_extensions', s:glsl_extensions)
  43. let profile = get(extensions, tolower(fnamemodify(bufname(a:buf), ':e')), 'gpu_vert')
  44. endif
  45. return profile
  46. endfunction " }}}2
  47. " }}}1
  48. call g:SyntasticRegistry.CreateAndRegisterChecker({
  49. \'filetype': 'glsl',
  50. \'name': 'cgc'})
  51. let &cpo = s:save_cpo
  52. unlet s:save_cpo
  53. " vim: set sw=4 sts=4 et fdm=marker: