vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

gnat.vim (5462B)


      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>
      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 "		14.10.2026 by Vim Project: quote project files in commands
     22 "    Help Page: compiler-gnat
     23 "------------------------------------------------------------------------------
     24 
     25 if version < 700
     26     finish
     27 endif
     28 
     29 function gnat#Make () dict					     " {{{1
     30    let &l:makeprg	 = self.Get_Command('Make')
     31    let &l:errorformat = self.Error_Format
     32    wall
     33    make
     34    copen
     35    set wrap
     36    wincmd W
     37 endfunction gnat#Make						     " }}}1
     38 
     39 function gnat#Pretty () dict					     " {{{1
     40    execute "!" . self.Get_Command('Pretty')
     41 endfunction gnat#Make						     " }}}1
     42 
     43 function gnat#Find () dict					     " {{{1
     44    execute "!" . self.Get_Command('Find')
     45 endfunction gnat#Find						     " }}}1
     46 
     47 function gnat#Tags () dict					     " {{{1
     48    execute "!" . self.Get_Command('Tags')
     49    edit tags
     50    call gnat#Insert_Tags_Header ()
     51    update
     52    quit
     53 endfunction gnat#Tags						     " }}}1
     54 
     55 function gnat#Set_Project_File (...) dict			     " {{{1
     56    if a:0 > 0
     57       let self.Project_File = a:1
     58 
     59       if ! filereadable (self.Project_File)
     60 	 let self.Project_File = findfile (
     61 	    \ fnamemodify (self.Project_File, ':r'),
     62 	    \ $ADA_PROJECT_PATH,
     63 	    \ 1)
     64       endif
     65    elseif strlen (self.Project_File) > 0
     66       let self.Project_File = browse (0, 'GNAT Project File?', '', self.Project_File)
     67    elseif expand ("%:e") == 'gpr'
     68       let self.Project_File = browse (0, 'GNAT Project File?', '', expand ("%:e"))
     69    else
     70       let self.Project_File = browse (0, 'GNAT Project File?', '', 'default.gpr')
     71    endif
     72 
     73    if strlen (v:this_session) > 0
     74       execute 'mksession! ' . v:this_session
     75    endif
     76 
     77    "if strlen (self.Project_File) > 0
     78       "if has("vms")
     79 	 "call ada#Switch_Session (
     80 	    "\ expand('~')[0:-2] . ".vimfiles.session]gnat_" .
     81 	    "\ fnamemodify (self.Project_File, ":t:r") . ".vim")
     82       "else
     83 	 "call ada#Switch_Session (
     84 	    "\ expand('~') . "/vimfiles/session/gnat_" .
     85 	    "\ fnamemodify (self.Project_File, ":t:r") . ".vim")
     86       "endif
     87    "else
     88       "call ada#Switch_Session ('')
     89    "endif
     90 
     91    return
     92 endfunction gnat#Set_Project_File				     " }}}1
     93 
     94 function gnat#Get_Command (Command) dict			     " {{{1
     95    let l:Command = eval ('self.' . a:Command . '_Command')
     96    return eval (l:Command)
     97 endfunction gnat#Get_Command					     " }}}1
     98 
     99 function gnat#Set_Session (...) dict				     " {{{1
    100    if argc() == 1 && fnamemodify (argv(0), ':e') == 'gpr'
    101       call self.Set_Project_File (argv(0))
    102    elseif  strlen (v:servername) > 0
    103       call self.Set_Project_File (v:servername . '.gpr')
    104    endif
    105 endfunction gnat#Set_Session					     " }}}1
    106 
    107 function gnat#New ()						     " {{{1
    108    let l:Retval = {
    109       \ 'Make'	      : function ('gnat#Make'),
    110       \ 'Pretty'	      : function ('gnat#Pretty'),
    111       \ 'Find'	      : function ('gnat#Find'),
    112       \ 'Tags'	      : function ('gnat#Tags'),
    113       \ 'Set_Project_File' : function ('gnat#Set_Project_File'),
    114       \ 'Set_Session'      : function ('gnat#Set_Session'),
    115       \ 'Get_Command'      : function ('gnat#Get_Command'),
    116       \ 'Project_File'     : '',
    117       \ 'Make_Command'     : '"gnat make -P " .   shellescape(self.Project_File, 1) . "  -F -gnatef  "',
    118       \ 'Pretty_Command'   : '"gnat pretty -P " . shellescape(self.Project_File, 1) . " "',
    119       \ 'Find_Command'     : '"gnat find -P " .   shellescape(self.Project_File, 1) . " -F "',
    120       \ 'Tags_Command'     : '"gnat xref -P " .   shellescape(self.Project_File, 1) . " -v  *.AD*"',
    121       \ 'Error_Format'     : '%f:%l:%c: %trror: %m,'   .
    122 			   \ '%f:%l:%c: %tarning: %m,' .
    123 			   \ '%f:%l:%c: (%ttyle) %m'}
    124 
    125    return l:Retval
    126 endfunction gnat#New						  " }}}1
    127 
    128 function gnat#Insert_Tags_Header ()				  " {{{1
    129    1insert
    130 !_TAG_FILE_FORMAT       1	 /extended format; --format=1 will not append ;" to lines/
    131 !_TAG_FILE_SORTED       1	 /0=unsorted, 1=sorted, 2=foldcase/
    132 !_TAG_PROGRAM_AUTHOR    AdaCore	 /info@adacore.com/
    133 !_TAG_PROGRAM_NAME      gnatxref //
    134 !_TAG_PROGRAM_URL       http://www.adacore.com  /official site/
    135 !_TAG_PROGRAM_VERSION   5.05w   //
    136 .
    137    return
    138 endfunction gnat#Insert_Tags_Header				  " }}}1
    139 
    140 finish " 1}}}
    141 
    142 "------------------------------------------------------------------------------
    143 "   Copyright (C) 2006  Martin Krischik
    144 "
    145 "   Vim is Charityware - see ":help license" or uganda.txt for licence details.
    146 "------------------------------------------------------------------------------
    147 " vim: textwidth=0 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
    148 " vim: foldmethod=marker