vim

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

ada.vim (7174B)


      1 "------------------------------------------------------------------------------
      2 "  Description: Perform Ada specific completion & tagging.
      3 "     Language: Ada (2005)
      4 "	   $Id: ada.vim 887 2008-07-08 14:29:01Z krischik $
      5 "   Maintainer: This runtime file is looking for a new maintainer.
      6 "   Previous Maintainer: Martin Krischik <krischik@users.sourceforge.net>
      7 "		Taylor Venable <taylor@metasyntax.net>
      8 "		Neil Bird <neil@fnxweb.com>
      9 "      $Author: krischik $
     10 "	 $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $
     11 "      Version: 4.6 with patch from David Bürgin
     12 "    $Revision: 887 $
     13 "     $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/ftplugin/ada.vim $
     14 "      History: 24.05.2006 MK Unified Headers
     15 "		26.05.2006 MK ' should not be in iskeyword.
     16 "		16.07.2006 MK Ada-Mode as vim-ball
     17 "		02.10.2006 MK Better folding.
     18 "		15.10.2006 MK Bram's suggestion for runtime integration
     19 "               05.11.2006 MK Bram suggested not to use include protection for
     20 "                             autoload
     21 "		05.11.2006 MK Bram suggested to save on spaces
     22 "		08.07.2007 TV fix default compiler problems.
     23 "		05.09.2025    do not globally set 'ignorecase'/'smartcase' option
     24 "			      set undo_ftplugin
     25 "			      mark as unmaintained
     26 "			      use buffer-local abbreviation
     27 "		27.06.2026    add recommended style guard
     28 "    Help Page: ft-ada-plugin
     29 "------------------------------------------------------------------------------
     30 " Provides mapping overrides for tag jumping that figure out the current
     31 " Ada object and tag jump to that, not the 'simple' vim word.
     32 " Similarly allows <Ctrl-N> matching of full-length ada entities from tags.
     33 "------------------------------------------------------------------------------
     34 
     35 " Only do this when not done yet for this buffer
     36 if exists ("b:did_ftplugin") || version < 700
     37    finish
     38 endif
     39 
     40 " Don't load another plugin for this buffer
     41 let b:did_ftplugin = 45
     42 
     43 "
     44 " Temporarily set cpoptions to ensure the script loads OK
     45 "
     46 let s:cpoptions = &cpoptions
     47 set cpoptions-=C
     48 
     49 " Section: Comments  {{{1
     50 "
     51 setlocal comments=O:--,:--\ \ 
     52 setlocal commentstring=--\ \ %s
     53 setlocal complete=.,w,b,u,t,i
     54 
     55 " Section: case	     {{{1
     56 "
     57 " setlocal nosmartcase
     58 " setlocal ignorecase
     59 
     60 " Section: formatoptions {{{1
     61 "
     62 setlocal formatoptions+=ron
     63 
     64 " Section: Tagging {{{1
     65 "
     66 if exists ("g:ada_extended_tagging")
     67    " Make local tag mappings for this buffer (if not already set)
     68    if g:ada_extended_tagging == 'jump'
     69       if mapcheck('<C-]>','n') == ''
     70 	 nnoremap <unique> <buffer> <C-]>    :call ada#Jump_Tag ('', 'tjump')<cr>
     71       endif
     72       if mapcheck('g<C-]>','n') == ''
     73 	 nnoremap <unique> <buffer> g<C-]>   :call ada#Jump_Tag ('','stjump')<cr>
     74       endif
     75    elseif g:ada_extended_tagging == 'list'
     76       if mapcheck('<C-]>','n') == ''
     77 	 nnoremap <unique> <buffer> <C-]>    :call ada#List_Tag ()<cr>
     78       endif
     79       if mapcheck('g<C-]>','n') == ''
     80 	 nnoremap <unique> <buffer> g<C-]>   :call ada#List_Tag ()<cr>
     81       endif
     82    endif
     83 endif
     84 
     85 " Section: Completion {{{1
     86 "
     87 setlocal completefunc=ada#User_Complete
     88 setlocal omnifunc=adacomplete#Complete
     89 
     90 if exists ("g:ada_extended_completion")
     91    if mapcheck ('<C-N>','i') == ''
     92       inoremap <unique> <buffer> <C-N> <C-R>=ada#Completion("\<lt>C-N>")<cr>
     93    endif
     94    if mapcheck ('<C-P>','i') == ''
     95       inoremap <unique> <buffer> <C-P> <C-R>=ada#Completion("\<lt>C-P>")<cr>
     96    endif
     97    if mapcheck ('<C-X><C-]>','i') == ''
     98       inoremap <unique> <buffer> <C-X><C-]> <C-R>=<SID>ada#Completion("\<lt>C-X>\<lt>C-]>")<cr>
     99    endif
    100    if mapcheck ('<bs>','i') == ''
    101       inoremap <silent> <unique> <buffer> <bs> <C-R>=ada#Insert_Backspace ()<cr>
    102    endif
    103 endif
    104 
    105 " Section: Matchit {{{1
    106 "
    107 " Only do this when not done yet for this buffer & matchit is used
    108 "
    109 if !exists ("b:match_words")  &&
    110   \ exists ("loaded_matchit")
    111    "
    112    " The following lines enable the macros/matchit.vim plugin for
    113    " Ada-specific extended matching with the % key.
    114    "
    115    let s:notend      = '\%(\<end\s\+\)\@<!'
    116    let b:match_words =
    117       \ s:notend . '\<if\>:\<elsif\>:\<else\>:\<end\>\s\+\<if\>,' .
    118       \ s:notend . '\<case\>:\<when\>:\<end\>\s\+\<case\>,' .
    119       \ '\%(\<while\>.*\|\<for\>.*\|'.s:notend.'\)\<loop\>:\<end\>\s\+\<loop\>,' .
    120       \ '\%(\<do\>\|\<begin\>\):\<exception\>:\<end\>\s*\%($\|[;A-Z]\),' .
    121       \ s:notend . '\<record\>:\<end\>\s\+\<record\>'
    122 endif
    123 
    124 " Section: Compiler {{{1
    125 "
    126 if ! exists("g:ada_default_compiler")
    127    if has("vms")
    128       let g:ada_default_compiler = 'decada'
    129    else
    130       let g:ada_default_compiler = 'gnat'
    131    endif
    132 endif
    133 
    134 if ! exists("current_compiler")			||
    135    \ current_compiler != g:ada_default_compiler
    136    execute "compiler " . g:ada_default_compiler
    137 endif
    138 
    139 " Section: Folding {{{1
    140 "
    141 if exists("g:ada_folding")
    142    if g:ada_folding[0] == 'i'
    143       setlocal foldmethod=indent
    144       setlocal foldignore=--
    145       setlocal foldnestmax=5
    146    elseif g:ada_folding[0] == 'g'
    147       setlocal foldmethod=expr
    148       setlocal foldexpr=ada#Pretty_Print_Folding(v:lnum)
    149    elseif g:ada_folding[0] == 's'
    150       setlocal foldmethod=syntax
    151    endif
    152    if get(g:, 'ada_recommended_style',
    153    \ get(g:, 'filetype_recommended_style', 1))
    154       setlocal tabstop=8
    155       setlocal softtabstop=3
    156       setlocal shiftwidth=3
    157    endif
    158 endif
    159 
    160 " Section: Abbrev {{{1
    161 "
    162 if exists("g:ada_abbrev")
    163    iabbrev <buffer> ret	return
    164    iabbrev <buffer> proc procedure
    165    iabbrev <buffer> pack package
    166    iabbrev <buffer> func function
    167 endif
    168 
    169 " Section: Commands, Mapping, Menus {{{1
    170 if !exists(':AdaTagFile')
    171   call ada#Map_Popup (
    172      \ 'Tag.List',
    173      \  'l',
    174      \ 'call ada#List_Tag ()')
    175   call ada#Map_Popup (
    176      \'Tag.Jump',
    177      \'j',
    178      \'call ada#Jump_Tag ()')
    179   call ada#Map_Menu (
    180      \'Tag.Create File',
    181      \':AdaTagFile',
    182      \'call ada#Create_Tags (''file'')')
    183   call ada#Map_Menu (
    184      \'Tag.Create Dir',
    185      \':AdaTagDir',
    186      \'call ada#Create_Tags (''dir'')')
    187 
    188   call ada#Map_Menu (
    189      \'Highlight.Toggle Space Errors',
    190      \ ':AdaSpaces',
    191      \'call ada#Switch_Syntax_Option (''space_errors'')')
    192   call ada#Map_Menu (
    193      \'Highlight.Toggle Lines Errors',
    194      \ ':AdaLines',
    195      \'call ada#Switch_Syntax_Option (''line_errors'')')
    196   call ada#Map_Menu (
    197      \'Highlight.Toggle Rainbow Color',
    198      \ ':AdaRainbow',
    199      \'call ada#Switch_Syntax_Option (''rainbow_color'')')
    200   call ada#Map_Menu (
    201      \'Highlight.Toggle Standard Types',
    202      \ ':AdaTypes',
    203      \'call ada#Switch_Syntax_Option (''standard_types'')')
    204 endif
    205 "
    206 " Section: b:undo_ftplugin {{{1
    207 let b:undo_ftplugin = "setl fo< comments< tw< commentstring< complete< "
    208 	\ . "| setl completefunc< omnifunc< ts< sts< sw< fdm< fde< fdi< "
    209 	\ . "| setl fdm< fde< fdi< fdn< "
    210 	\ . "| unlet! b:match_words "
    211 
    212 " 1}}}
    213 " Reset cpoptions
    214 let &cpoptions = s:cpoptions
    215 unlet s:cpoptions
    216 
    217 finish " 1}}}
    218 
    219 "------------------------------------------------------------------------------
    220 "   Copyright (C) 2006	Martin Krischik
    221 "
    222 "   Vim is Charityware - see ":help license" or uganda.txt for licence details.
    223 "------------------------------------------------------------------------------
    224 " vim: textwidth=78 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
    225 " vim: foldmethod=marker