10dc065eeSBram Moolenaar" Vim filetype plugin file 2071d4279SBram Moolenaar" Language: MetaPost 32ec618c9SBram Moolenaar" Maintainer: Nicola Vitacolonna <[email protected]> 42ec618c9SBram Moolenaar" Former Maintainers: Nikolai Weibull <[email protected]> 5*dc083288SBram Moolenaar" Latest Revision: 2016 Oct 2 6071d4279SBram Moolenaar 70dc065eeSBram Moolenaarif exists("b:did_ftplugin") 80dc065eeSBram Moolenaar finish 90dc065eeSBram Moolenaarendif 100dc065eeSBram Moolenaarlet b:did_ftplugin = 1 110dc065eeSBram Moolenaar 12e37d50a5SBram Moolenaarlet s:cpo_save = &cpo 13e37d50a5SBram Moolenaarset cpo&vim 14e37d50a5SBram Moolenaar 152ec618c9SBram Moolenaarlet b:undo_ftplugin = "setl com< cms< fo< sua< inc< def< ofu<" 162ec618c9SBram Moolenaar \ . "| unlet! b:match_ignorecase b:match_words b:match_skip" 170dc065eeSBram Moolenaar 182ec618c9SBram Moolenaarsetlocal comments=:% commentstring=%\ %s formatoptions-=t formatoptions+=cjroql2 192ec618c9SBram Moolenaarsetlocal suffixesadd=.mp,.mpiv 202ec618c9SBram Moolenaarlet &l:include = '\<\%(input\|loadmodule\)\>' " loadmodule is in MetaFun 212ec618c9SBram Moolenaarlet &l:define = '\<\%(let\|newinternal\|interim\|def\|vardef\)\>\|\<\%(primary\|secondary\|tertiary\)def\>\s*[^ .]\+' 222ec618c9SBram Moolenaarsetlocal omnifunc=syntaxcomplete#Complete 232ec618c9SBram Moolenaarlet g:omni_syntax_group_include_mp = 'mf\w\+,mp\w\+' 242ec618c9SBram Moolenaarlet g:omni_syntax_group_exclude_mp = 'mfTodoComment' 250dc065eeSBram Moolenaar 2610c56952SBram Moolenaarif exists(":FixBeginfigs") != 2 270dc065eeSBram Moolenaar command -nargs=0 FixBeginfigs call s:fix_beginfigs() 280dc065eeSBram Moolenaar 290dc065eeSBram Moolenaar function! s:fix_beginfigs() 300dc065eeSBram Moolenaar let i = 1 310dc065eeSBram Moolenaar g/^beginfig(\d*);$/s//\='beginfig('.i.');'/ | let i = i + 1 320dc065eeSBram Moolenaar endfunction 330dc065eeSBram Moolenaarendif 34e37d50a5SBram Moolenaar 352ec618c9SBram Moolenaarlet s:mp_regex = { 362ec618c9SBram Moolenaar \ 'beginsection' : '^\s*\%(\%(\|var\|primary\|secondary\|tertiary\)def\|begin\%(fig\|char\|logochar\|glyph\|graph\)\)\>', 37*dc083288SBram Moolenaar \ 'endsection' : '^\s*\%(enddef\|end\%(fig\|char\|glyph\|graph\)\)\>', 382ec618c9SBram Moolenaar \ 'beginblock' : '^\s*\%(begingroup\|if\|for\%(\|suffixes\|ever\)\)\>', 392ec618c9SBram Moolenaar \ 'endblock' : '^\s*\%(endgroup\|fi\|endfor\)\>' 402ec618c9SBram Moolenaar \ } 412ec618c9SBram Moolenaar 422ec618c9SBram Moolenaarfunction! s:move_around(count, what, flags, visual) 432ec618c9SBram Moolenaar if a:visual 442ec618c9SBram Moolenaar exe "normal! gv" 452ec618c9SBram Moolenaar endif 462ec618c9SBram Moolenaar call search(s:mp_regex[a:what], a:flags.'s') " 's' sets previous context mark 47*dc083288SBram Moolenaar call map(range(2, a:count), 'search(s:mp_regex[a:what], a:flags)') 482ec618c9SBram Moolenaarendfunction 492ec618c9SBram Moolenaar 502ec618c9SBram Moolenaar 512ec618c9SBram Moolenaar" Move around macros. 522ec618c9SBram Moolenaarnnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:false) <CR> 532ec618c9SBram Moolenaarvnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:true) <CR> 542ec618c9SBram Moolenaarnnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:false) <CR> 552ec618c9SBram Moolenaarvnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:true) <CR> 562ec618c9SBram Moolenaarnnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:false) <CR> 572ec618c9SBram Moolenaarvnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:true) <CR> 582ec618c9SBram Moolenaarnnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:false) <CR> 592ec618c9SBram Moolenaarvnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:true) <CR> 602ec618c9SBram Moolenaarnnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:false) <CR> 612ec618c9SBram Moolenaarvnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:true) <CR> 622ec618c9SBram Moolenaarnnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:false) <CR> 632ec618c9SBram Moolenaarvnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:true) <CR> 642ec618c9SBram Moolenaar 652ec618c9SBram Moolenaarif exists("loaded_matchit") 662ec618c9SBram Moolenaar let b:match_ignorecase = 0 672ec618c9SBram Moolenaar let b:match_words = 682ec618c9SBram Moolenaar \ '\<if\>:\<else\%[if]\>:\<fi\>,' . 692ec618c9SBram Moolenaar \ '\<for\%(\|suffixes\|ever\)\>:\<exit\%(if\|unless\)\>:\<endfor\>,' . 702ec618c9SBram Moolenaar \ '\<\%(\|var\|primary\|secondary\|tertiary\)def\>:\<enddef\>,' . 712ec618c9SBram Moolenaar \ '\<beginfig\>:\<endfig\>,' . 722ec618c9SBram Moolenaar \ '\<begingroup\>:\<endgroup\>,' . 73*dc083288SBram Moolenaar \ '\<begin\%(logo\)\?char\>:\<endchar\>,' . 74*dc083288SBram Moolenaar \ '\<beginglyph\>:\<endglyph\>,' . 752ec618c9SBram Moolenaar \ '\<begingraph\>:\<endgraph\>' 762ec618c9SBram Moolenaar " Ignore comments and strings 772ec618c9SBram Moolenaar let b:match_skip = 'synIDattr(synID(line("."), col("."), 1), "name") 782ec618c9SBram Moolenaar \ =~# "^mf\\%(Comment\\|String\\|\\)$\\|^mpTeXinsert$"' 792ec618c9SBram Moolenaarendif 802ec618c9SBram Moolenaar 81e37d50a5SBram Moolenaarlet &cpo = s:cpo_save 82e37d50a5SBram Moolenaarunlet s:cpo_save 83