1" Vim filetype plugin 2" Language: Eiffel 3" Maintainer: Doug Kearns <[email protected]> 4" Last Change: 2010 Aug 29 5 6if (exists("b:did_ftplugin")) 7 finish 8endif 9let b:did_ftplugin = 1 10 11let s:cpo_save = &cpo 12set cpo&vim 13 14setlocal comments=:-- 15setlocal commentstring=--\ %s 16 17setlocal formatoptions-=t formatoptions+=croql 18 19if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") 20 let b:browsefilter = "Eiffel Source Files (*.e)\t*.e\n" . 21 \ "Eiffel Control Files (*.ecf, *.ace, *.xace)\t*.ecf;*.ace;*.xace\n" . 22 \ "All Files (*.*)\t*.*\n" 23endif 24 25if exists("loaded_matchit") && !exists("b:match_words") 26 let b:match_ignorecase = 0 27 " Silly \%^ trick to match note at head of pair and in middle prevents 28 " 'g%' wrapping from 'note' to 'end' 29 let b:match_words = '\%^:' . 30 \ '\<\%(^note\|indexing\|class\|^obsolete\|inherit\|insert\|^create\|convert\|feature\|^invariant\)\>:' . 31 \ '^end\>,' . 32 \ '\<\%(do\|deferred\|external\|once\%(\s\+"\)\@!\|check\|debug\|if\|inspect\|from\|across\)\>:' . 33 \ '\%(\%(^\s\+\)\@<=\%(then\|until\|loop\)\|\%(then\|until\|loop\)\s\+[^ -]\|' . 34 \ '\<\%(ensure\%(\s\+then\)\=\|rescue\|_then\|elseif\|else\|when\|\s\@<=invariant\|_until\|_loop\|variant\|_as\|alias\)\>\):' . 35 \ '\s\@<=end\>' 36 let b:match_skip = 's:\<eiffel\%(Comment\|String\|Operator\)\>' 37 noremap [% <Nop> 38 noremap ]% <Nop> 39 vnoremap a% <Nop> 40endif 41 42let b:undo_ftplugin = "setl fo< com< cms<" . 43 \ "| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip" 44 45if !exists("g:no_plugin_maps") && !exists("g:no_eiffel_maps") 46 function! s:DoMotion(pattern, count, flags) abort 47 normal! m' 48 for i in range(a:count) 49 call search(a:pattern, a:flags) 50 endfor 51 endfunction 52 53 let sections = '^\%(note\|indexing\|' . 54 \ '\%(\%(deferred\|expanded\|external\|frozen\)\s\+\)*class\|' . 55 \ 'obsolete\|inherit\|insert\|create\|convert\|feature\|' . 56 \ 'invariant\|end\)\>' 57 58 nnoremap <silent> <buffer> ]] :<C-U>call <SID>DoMotion(sections, v:count1, 'W')<CR> 59 xnoremap <silent> <buffer> ]] :<C-U>exe "normal! gv"<Bar>call <SID>DoMotion(sections, v:count1, 'W')<CR> 60 nnoremap <silent> <buffer> [[ :<C-U>call <SID>DoMotion(sections, v:count1, 'Wb')<CR> 61 xnoremap <silent> <buffer> [[ :<C-U>exe "normal! gv"<Bar>call <SID>DoMotion(sections, v:count1, 'Wb')<CR> 62 63 function! s:DoFeatureMotion(count, flags) 64 let view = winsaveview() 65 call cursor(1, 1) 66 let [features_start, _] = searchpos('^feature\>') 67 call search('^\s\+\a') " find the first feature 68 let spaces = indent(line('.')) 69 let [features_end, _] = searchpos('^\%(invariant\|note\|end\)\>') 70 call winrestview(view) 71 call s:DoMotion('\%>' . features_start . 'l\%<' . features_end . 'l^\s*\%' . (spaces + 1) . 'v\zs\a', a:count, a:flags) 72 endfunction 73 74 nnoremap <silent> <buffer> ]m :<C-U>call <SID>DoFeatureMotion(v:count1, 'W')<CR> 75 xnoremap <silent> <buffer> ]m :<C-U>exe "normal! gv"<Bar>call <SID>DoFeatureMotion(v:count1, 'W')<CR> 76 nnoremap <silent> <buffer> [m :<C-U>call <SID>DoFeatureMotion(v:count1, 'Wb')<CR> 77 xnoremap <silent> <buffer> [m :<C-U>exe "normal! gv"<Bar>call <SID>DoFeatureMotion(v:count1, 'Wb')<CR> 78 79 let comment_block_start = '^\%(\s\+--.*\n\)\@<!\s\+--' 80 let comment_block_end = '^\s\+--.*\n\%(\s\+--\)\@!' 81 82 nnoremap <silent> <buffer> ]- :<C-U>call <SID>DoMotion(comment_block_start, 1, 'W')<CR> 83 xnoremap <silent> <buffer> ]- :<C-U>exe "normal! gv"<Bar>call <SID>DoMotion(comment_block_start, 1, 'W')<CR> 84 nnoremap <silent> <buffer> [- :<C-U>call <SID>DoMotion(comment_block_end, 1, 'Wb')<CR> 85 xnoremap <silent> <buffer> [- :<C-U>exe "normal! gv"<Bar>call <SID>DoMotion(comment_block_end, 1, 'Wb')<CR> 86 87 let b:undo_ftplugin = b:undo_ftplugin . 88 \ "| silent! execute 'unmap <buffer> [[' | silent! execute 'unmap <buffer> ]]'" . 89 \ "| silent! execute 'unmap <buffer> [m' | silent! execute 'unmap <buffer> ]m'" . 90 \ "| silent! execute 'unmap <buffer> [-' | silent! execute 'unmap <buffer> ]-'" 91endif 92 93let &cpo = s:cpo_save 94unlet s:cpo_save 95 96" vim: nowrap sw=2 sts=2 ts=8 97