gnat.vim 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. "------------------------------------------------------------------------------
  2. " Description: Vim Ada/GNAT compiler file
  3. " Language: Ada (GNAT)
  4. " $Id: gnat.vim 887 2008-07-08 14:29:01Z krischik $
  5. " Copyright: Copyright (C) 2006 Martin Krischik
  6. " Maintainer: Martin Krischi <krischik@users.sourceforge.net>k
  7. " Ned Okie <nokie@radford.edu>
  8. " $Author: krischik $
  9. " $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $
  10. " Version: 4.6
  11. " $Revision: 887 $
  12. " $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/gnat.vim $
  13. " History: 24.05.2006 MK Unified Headers
  14. " 16.07.2006 MK Ada-Mode as vim-ball
  15. " 05.08.2006 MK Add session support
  16. " 15.10.2006 MK Bram's suggestion for runtime integration
  17. " 05.11.2006 MK Bram suggested not to use include protection for
  18. " autoload
  19. " 05.11.2006 MK Bram suggested to save on spaces
  20. " 19.09.2007 NO use project file only when there is a project
  21. " Help Page: compiler-gnat
  22. "------------------------------------------------------------------------------
  23. if version < 700
  24. finish
  25. endif
  26. function gnat#Make () dict " {{{1
  27. let &l:makeprg = self.Get_Command('Make')
  28. let &l:errorformat = self.Error_Format
  29. wall
  30. make
  31. copen
  32. set wrap
  33. wincmd W
  34. endfunction gnat#Make " }}}1
  35. function gnat#Pretty () dict " {{{1
  36. execute "!" . self.Get_Command('Pretty')
  37. endfunction gnat#Make " }}}1
  38. function gnat#Find () dict " {{{1
  39. execute "!" . self.Get_Command('Find')
  40. endfunction gnat#Find " }}}1
  41. function gnat#Tags () dict " {{{1
  42. execute "!" . self.Get_Command('Tags')
  43. edit tags
  44. call gnat#Insert_Tags_Header ()
  45. update
  46. quit
  47. endfunction gnat#Tags " }}}1
  48. function gnat#Set_Project_File (...) dict " {{{1
  49. if a:0 > 0
  50. let self.Project_File = a:1
  51. if ! filereadable (self.Project_File)
  52. let self.Project_File = findfile (
  53. \ fnamemodify (self.Project_File, ':r'),
  54. \ $ADA_PROJECT_PATH,
  55. \ 1)
  56. endif
  57. elseif strlen (self.Project_File) > 0
  58. let self.Project_File = browse (0, 'GNAT Project File?', '', self.Project_File)
  59. elseif expand ("%:e") == 'gpr'
  60. let self.Project_File = browse (0, 'GNAT Project File?', '', expand ("%:e"))
  61. else
  62. let self.Project_File = browse (0, 'GNAT Project File?', '', 'default.gpr')
  63. endif
  64. if strlen (v:this_session) > 0
  65. execute 'mksession! ' . v:this_session
  66. endif
  67. "if strlen (self.Project_File) > 0
  68. "if has("vms")
  69. "call ada#Switch_Session (
  70. "\ expand('~')[0:-2] . ".vimfiles.session]gnat_" .
  71. "\ fnamemodify (self.Project_File, ":t:r") . ".vim")
  72. "else
  73. "call ada#Switch_Session (
  74. "\ expand('~') . "/vimfiles/session/gnat_" .
  75. "\ fnamemodify (self.Project_File, ":t:r") . ".vim")
  76. "endif
  77. "else
  78. "call ada#Switch_Session ('')
  79. "endif
  80. return
  81. endfunction gnat#Set_Project_File " }}}1
  82. function gnat#Get_Command (Command) dict " {{{1
  83. let l:Command = eval ('self.' . a:Command . '_Command')
  84. return eval (l:Command)
  85. endfunction gnat#Get_Command " }}}1
  86. function gnat#Set_Session (...) dict " {{{1
  87. if argc() == 1 && fnamemodify (argv(0), ':e') == 'gpr'
  88. call self.Set_Project_File (argv(0))
  89. elseif strlen (v:servername) > 0
  90. call self.Set_Project_File (v:servername . '.gpr')
  91. endif
  92. endfunction gnat#Set_Session " }}}1
  93. function gnat#New () " {{{1
  94. let l:Retval = {
  95. \ 'Make' : function ('gnat#Make'),
  96. \ 'Pretty' : function ('gnat#Pretty'),
  97. \ 'Find' : function ('gnat#Find'),
  98. \ 'Tags' : function ('gnat#Tags'),
  99. \ 'Set_Project_File' : function ('gnat#Set_Project_File'),
  100. \ 'Set_Session' : function ('gnat#Set_Session'),
  101. \ 'Get_Command' : function ('gnat#Get_Command'),
  102. \ 'Project_File' : '',
  103. \ 'Make_Command' : '"gnat make -P " . self.Project_File . " -F -gnatef "',
  104. \ 'Pretty_Command' : '"gnat pretty -P " . self.Project_File . " "',
  105. \ 'Find_Program' : '"gnat find -P " . self.Project_File . " -F "',
  106. \ 'Tags_Command' : '"gnat xref -P " . self.Project_File . " -v *.AD*"',
  107. \ 'Error_Format' : '%f:%l:%c: %trror: %m,' .
  108. \ '%f:%l:%c: %tarning: %m,' .
  109. \ '%f:%l:%c: (%ttyle) %m'}
  110. return l:Retval
  111. endfunction gnat#New " }}}1
  112. function gnat#Insert_Tags_Header () " {{{1
  113. 1insert
  114. !_TAG_FILE_FORMAT 1 /extended format; --format=1 will not append ;" to lines/
  115. !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
  116. !_TAG_PROGRAM_AUTHOR AdaCore /info@adacore.com/
  117. !_TAG_PROGRAM_NAME gnatxref //
  118. !_TAG_PROGRAM_URL http://www.adacore.com /official site/
  119. !_TAG_PROGRAM_VERSION 5.05w //
  120. .
  121. return
  122. endfunction gnat#Insert_Tags_Header " }}}1
  123. finish " 1}}}
  124. "------------------------------------------------------------------------------
  125. " Copyright (C) 2006 Martin Krischik
  126. "
  127. " Vim is Charityware - see ":help license" or uganda.txt for licence details.
  128. "------------------------------------------------------------------------------
  129. " vim: textwidth=0 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
  130. " vim: foldmethod=marker