dmd.vim 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "============================================================================
  2. "File: d.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: Alfredo Di Napoli <alfredo dot dinapoli at gmail dot com>
  5. "License: Based on the original work of Gregor Uhlenheuer and his
  6. " cpp.vim checker so credits are dued.
  7. " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  8. " EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  9. " OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  10. " NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  11. " HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  12. " WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  13. " FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  14. " OTHER DEALINGS IN THE SOFTWARE.
  15. "
  16. "============================================================================
  17. if exists('g:loaded_syntastic_d_dmd_checker')
  18. finish
  19. endif
  20. let g:loaded_syntastic_d_dmd_checker = 1
  21. if !exists('g:syntastic_d_compiler_options')
  22. let g:syntastic_d_compiler_options = ''
  23. endif
  24. let s:save_cpo = &cpo
  25. set cpo&vim
  26. function! SyntaxCheckers_d_dmd_IsAvailable() dict
  27. if !exists('g:syntastic_d_compiler')
  28. let g:syntastic_d_compiler = self.getExec()
  29. endif
  30. call self.log('g:syntastic_d_compiler =', g:syntastic_d_compiler)
  31. return executable(expand(g:syntastic_d_compiler, 1))
  32. endfunction
  33. function! SyntaxCheckers_d_dmd_GetLocList() dict
  34. if !exists('g:syntastic_d_include_dirs')
  35. let g:syntastic_d_include_dirs = filter(glob($HOME . '/.dub/packages/*', 1, 1), 'isdirectory(v:val)')
  36. call map(g:syntastic_d_include_dirs, 'isdirectory(v:val . "/source") ? v:val . "/source" : v:val')
  37. call add(g:syntastic_d_include_dirs, './source')
  38. endif
  39. return syntastic#c#GetLocList('d', 'dmd', {
  40. \ 'errorformat':
  41. \ '%-G%f:%s:,%f(%l): %m,' .
  42. \ '%f:%l: %m',
  43. \ 'main_flags': '-c -of' . syntastic#util#DevNull(),
  44. \ 'header_names': '\m\.di$' })
  45. endfunction
  46. call g:SyntasticRegistry.CreateAndRegisterChecker({
  47. \ 'filetype': 'd',
  48. \ 'name': 'dmd' })
  49. let &cpo = s:save_cpo
  50. unlet s:save_cpo
  51. " vim: set sw=4 sts=4 et fdm=marker: