nvcc.vim 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. let s:save_cpo = &cpo
  12. set cpo&vim
  13. function! SyntaxCheckers_cuda_nvcc_GetLocList() dict
  14. let buf = bufnr('')
  15. let arch_flag = syntastic#util#bufVar(buf, 'cuda_arch')
  16. if arch_flag !=# ''
  17. let arch_flag = '-arch=' . arch_flag
  18. call syntastic#log#oneTimeWarn('variable g:syntastic_cuda_arch is deprecated, ' .
  19. \ 'please add ' . string(arch_flag) . ' to g:syntastic_cuda_nvcc_args instead')
  20. endif
  21. let build_opts = {}
  22. let dummy = ''
  23. if index(['h', 'hpp', 'cuh'], fnamemodify(bufname(buf), ':e'), 0, 1) >= 0
  24. if syntastic#util#bufVar(buf, 'cuda_check_header', 0)
  25. let dummy = fnamemodify(bufname(buf), ':p:h') . syntastic#util#Slash() . '.syntastic_dummy.cu'
  26. let build_opts = {
  27. \ 'exe_before': 'echo > ' . syntastic#util#shescape(dummy) . ' ;',
  28. \ 'fname_before': '.syntastic_dummy.cu -include' }
  29. else
  30. return []
  31. endif
  32. endif
  33. call extend(build_opts, {
  34. \ 'args_before': arch_flag . ' --cuda -O0 -I .',
  35. \ 'args': syntastic#c#ReadConfig(syntastic#util#bufVar(buf, 'cuda_config_file')),
  36. \ 'args_after': '-Xcompiler -fsyntax-only',
  37. \ 'tail_after': syntastic#c#NullOutput() })
  38. let makeprg = self.makeprgBuild(build_opts)
  39. let errorformat =
  40. \ '%*[^"]"%f"%*\D%l: %m,'.
  41. \ '"%f"%*\D%l: %m,'.
  42. \ '%-G%f:%l: (Each undeclared identifier is reported only once,'.
  43. \ '%-G%f:%l: for each function it appears in.),'.
  44. \ '%f:%l:%c:%m,'.
  45. \ '%f(%l):%m,'.
  46. \ '%f:%l:%m,'.
  47. \ '"%f"\, line %l%*\D%c%*[^ ] %m,'.
  48. \ '%D%*\a[%*\d]: Entering directory `%f'','.
  49. \ '%X%*\a[%*\d]: Leaving directory `%f'','.
  50. \ '%D%*\a: Entering directory `%f'','.
  51. \ '%X%*\a: Leaving directory `%f'','.
  52. \ '%DMaking %*\a in %f,'.
  53. \ '%f|%l| %m'
  54. let loclist = SyntasticMake({
  55. \ 'makeprg': makeprg,
  56. \ 'errorformat': errorformat,
  57. \ 'defaults': {'type': 'E'} })
  58. for e in loclist
  59. let pat = matchstr(e['text'], '\m\c^\s*warning:\s*\zs.*')
  60. if pat !=# ''
  61. let e['text'] = pat
  62. let e['type'] = 'W'
  63. endif
  64. endfor
  65. if dummy !=# ''
  66. call delete(dummy)
  67. endif
  68. return loclist
  69. endfunction
  70. call g:SyntasticRegistry.CreateAndRegisterChecker({
  71. \ 'filetype': 'cuda',
  72. \ 'name': 'nvcc'})
  73. let &cpo = s:save_cpo
  74. unlet s:save_cpo
  75. " vim: set sw=4 sts=4 et fdm=marker: