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