nvcc.vim 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. "============================================================================
  2. "File: cuda.vim
  3. "Description: Syntax checking plugin for syntastic
  4. "Author: Hannes Schulz <schulz at ais dot uni-bonn dot de>
  5. "
  6. "============================================================================
  7. if exists('g:loaded_syntastic_cuda_nvcc_checker')
  8. finish
  9. endif
  10. let g:loaded_syntastic_cuda_nvcc_checker = 1
  11. if !exists('g:syntastic_cuda_config_file')
  12. let g:syntastic_cuda_config_file = '.syntastic_cuda_config'
  13. endif
  14. let s:save_cpo = &cpo
  15. set cpo&vim
  16. function! SyntaxCheckers_cuda_nvcc_GetLocList() dict
  17. let arch_flag = syntastic#util#var('cuda_arch')
  18. if arch_flag !=# ''
  19. let arch_flag = '-arch=' . arch_flag
  20. call syntastic#log#oneTimeWarn('variable g:syntastic_cuda_arch is deprecated, ' .
  21. \ 'please add ' . string(arch_flag) . ' to g:syntastic_cuda_nvcc_args instead')
  22. endif
  23. let build_opts = {}
  24. let dummy = ''
  25. if index(['h', 'hpp', 'cuh'], expand('%:e', 1), 0, 1) >= 0
  26. if syntastic#util#var('cuda_check_header', 0)
  27. let dummy = expand('%:p:h', 1) . syntastic#util#Slash() . '.syntastic_dummy.cu'
  28. let build_opts = {
  29. \ 'exe_before': 'echo > ' . syntastic#util#shescape(dummy) . ' ;',
  30. \ 'fname_before': '.syntastic_dummy.cu -include' }
  31. else
  32. return []
  33. endif
  34. endif
  35. call extend(build_opts, {
  36. \ 'args_before': arch_flag . ' --cuda -O0 -I .',
  37. \ 'args': syntastic#c#ReadConfig(g:syntastic_cuda_config_file),
  38. \ 'args_after': '-Xcompiler -fsyntax-only',
  39. \ 'tail_after': syntastic#c#NullOutput() })
  40. let makeprg = self.makeprgBuild(build_opts)
  41. let errorformat =
  42. \ '%*[^"]"%f"%*\D%l: %m,'.
  43. \ '"%f"%*\D%l: %m,'.
  44. \ '%-G%f:%l: (Each undeclared identifier is reported only once,'.
  45. \ '%-G%f:%l: for each function it appears in.),'.
  46. \ '%f:%l:%c:%m,'.
  47. \ '%f(%l):%m,'.
  48. \ '%f:%l:%m,'.
  49. \ '"%f"\, line %l%*\D%c%*[^ ] %m,'.
  50. \ '%D%*\a[%*\d]: Entering directory `%f'','.
  51. \ '%X%*\a[%*\d]: Leaving directory `%f'','.
  52. \ '%D%*\a: Entering directory `%f'','.
  53. \ '%X%*\a: Leaving directory `%f'','.
  54. \ '%DMaking %*\a in %f,'.
  55. \ '%f|%l| %m'
  56. let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
  57. if dummy !=# ''
  58. call delete(dummy)
  59. endif
  60. return loclist
  61. endfunction
  62. call g:SyntasticRegistry.CreateAndRegisterChecker({
  63. \ 'filetype': 'cuda',
  64. \ 'name': 'nvcc'})
  65. let &cpo = s:save_cpo
  66. unlet s:save_cpo
  67. " vim: set sw=4 sts=4 et fdm=marker: