gcc.vim 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "============================================================================
  2. "File: gcc.vim
  3. "Description: Syntax checking for at&t and intel assembly files with gcc
  4. "Maintainer: Josh 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_asm_gcc_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_asm_gcc_checker = 1
  16. if !exists('g:syntastic_asm_compiler_options')
  17. let g:syntastic_asm_compiler_options = ''
  18. endif
  19. if !exists('g:syntastic_asm_generic')
  20. let g:syntastic_asm_generic = 0
  21. endif
  22. let s:save_cpo = &cpo
  23. set cpo&vim
  24. function! SyntaxCheckers_asm_gcc_IsAvailable() dict " {{{1
  25. if !exists('g:syntastic_asm_compiler')
  26. let g:syntastic_asm_compiler = self.getExec()
  27. endif
  28. return executable(expand(g:syntastic_asm_compiler, 1))
  29. endfunction " }}}1
  30. function! SyntaxCheckers_asm_gcc_GetLocList() dict " {{{1
  31. let buf = bufnr('')
  32. return syntastic#c#GetLocList('asm', 'gcc', {
  33. \ 'errorformat':
  34. \ '%-G%f:%s:,' .
  35. \ '%f:%l:%c: %trror: %m,' .
  36. \ '%f:%l:%c: %tarning: %m,' .
  37. \ '%f:%l: %m',
  38. \ 'main_flags': '-x assembler -fsyntax-only' . (g:syntastic_asm_generic ? '' : ' -masm=' . s:GetDialect(buf)) })
  39. endfunction " }}}1
  40. " Utilities {{{1
  41. function! s:GetDialect(buf) " {{{2
  42. return syntastic#util#bufVar(a:buf, 'asm_dialect', fnamemodify(bufname(a:buf), ':e') ==? 'asm' ? 'intel' : 'att')
  43. endfunction " }}}2
  44. " }}}1
  45. call g:SyntasticRegistry.CreateAndRegisterChecker({
  46. \ 'filetype': 'asm',
  47. \ 'name': 'gcc' })
  48. let &cpo = s:save_cpo
  49. unlet s:save_cpo
  50. " vim: set sw=4 sts=4 et fdm=marker: