robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
88085c2e80
master
1" Vim filetype plugin file 2" Language: ConTeXt typesetting engine 3" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com> 4" Former Maintainers: Nikolai Weibull <now@bitwi.se> 5" Latest Revision: 2021 Oct 15 6 7if exists ( "b:did_ftplugin" ) 8finish 9endif 10let b: did_ftplugin = 1 11 12let s: cpo_save = & cpo 13set cpo & vim 14 15let b: undo_ftplugin = "setl com< cms< def< inc< sua< fo< ofu<" 16 17setlocal comments = b:%D,b:%C,b:%M,:%commentstring = %\ %sformatoptions += tjcroql2 18if get ( b:, 'context_metapost' , get ( g:, 'context_metapost' , 1 )) 19setlocal omnifunc = contextcomplete#Complete 20let g: omni_syntax_group_include_context = 'mf\w\+,mp\w\+' 21let g: omni_syntax_group_exclude_context = 'mfTodoComment' 22endif 23 24let & l: define = '\\\%([egx]\|char\|mathchar\|count\|dimen\|muskip\|skip\|toks\)\=' 25 \. 'def\|\\font\|\\\%(future\)\=let' 26 \. '\|\\new\%(count\|dimen\|skip\|muskip\|box\|toks\|read\|write' 27 \. '\|fam\|insert\|if\)' 28 29let & l: include = '^\s*\\\%(input\|component\|product\|project\|environment\)' 30 31setlocal suffixesadd = .tex 32 33if exists ( "loaded_matchit" ) && ! exists ( "b:match_words" ) 34let b: match_ignorecase = 0 35let b: match_skip = 'r:\\\@<!\%(\\\\\)*%' 36let b: match_words = '(:),\[:],{:},\\(:\\),\\\[:\\],' . 37 \'\\start\(\a\+\):\\stop\1' 38let b: undo_ftplugin .= " | unlet! b:match_ignorecase b:match_words b:match_skip" 39endif 40 41let s: context_regex = { 42 \'beginsection' : '\\\%(start\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>' , 43 \'endsection' : '\\\%(stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>' , 44 \'beginblock' : '\\\%(start\|setup\|define\)' , 45 \'endblock' : '\\\%(stop\|setup\|define\)' 46 \} 47 48function ! s: move_around ( count , what , flags , visual ) 49if a: visual 50exe "normal! gv" 51endif 52call search ( s: context_regex [ a: what ], a: flags . 's' ) " 's' sets previous context mark 53call map ( range ( 2 , a: count ), 'search(s:context_regex[a:what], a:flags)' ) 54endfunction 55 56if ! exists ( "no_plugin_maps" ) && ! exists ( "no_context_maps" ) 57" Move around macros. 58nnoremap <silent><buffer> [[ :< C-U > call< SID > move_around(v:count1, "beginsection", "bW", v:false)< CR > 59vnoremap <silent><buffer> [[ :< C-U > call< SID > move_around(v:count1, "beginsection", "bW", v:true)< CR > 60nnoremap <silent><buffer> ]] :< C-U > call< SID > move_around(v:count1, "beginsection", "W", v:false)< CR > 61vnoremap <silent><buffer> ]] :< C-U > call< SID > move_around(v:count1, "beginsection", "W", v:true)< CR > 62nnoremap <silent><buffer> [] :< C-U > call< SID > move_around(v:count1, "endsection", "bW", v:false)< CR > 63vnoremap <silent><buffer> [] :< C-U > call< SID > move_around(v:count1, "endsection", "bW", v:true)< CR > 64nnoremap <silent><buffer> ][ :< C-U > call< SID > move_around(v:count1, "endsection", "W", v:false)< CR > 65vnoremap <silent><buffer> ][ :< C-U > call< SID > move_around(v:count1, "endsection", "W", v:true)< CR > 66nnoremap <silent><buffer> [{ :< C-U > call< SID > move_around(v:count1, "beginblock", "bW", v:false)< CR > 67vnoremap <silent><buffer> [{ :< C-U > call< SID > move_around(v:count1, "beginblock", "bW", v:true)< CR > 68nnoremap <silent><buffer> ]} :< C-U > call< SID > move_around(v:count1, "endblock", "W", v:false)< CR > 69vnoremap <silent><buffer> ]} :< C-U > call< SID > move_around(v:count1, "endblock", "W", v:true)< CR > 70 71let b: undo_ftplugin .= " | sil! exe 'nunmap <buffer> [[' | sil! exe 'vunmap <buffer> [['" . 72 \" | sil! exe 'nunmap <buffer> ]]' | sil! exe 'vunmap <buffer> ]]'" . 73 \" | sil! exe 'nunmap <buffer> []' | sil! exe 'vunmap <buffer> []'" . 74 \" | sil! exe 'nunmap <buffer> ][' | sil! exe 'vunmap <buffer> ]['" . 75 \" | sil! exe 'nunmap <buffer> [{' | sil! exe 'vunmap <buffer> [{'" . 76 \" | sil! exe 'nunmap <buffer> ]}' | sil! exe 'vunmap <buffer> ]}'" 77end 78 79" Other useful mappings 80if get ( g:, 'context_mappings' , 1 ) 81let s: tp_regex = '?^$\|^\s*\\\(item\|start\|stop\|blank\|\%(sub\)*section\|chapter\|\%(sub\)*subject\|title\|part\)' 82 83fun ! s: tp () 84call cursor ( search ( s: tp_regex , 'bcW' ) + 1 , 1 ) 85normal ! V 86call cursor ( search ( s: tp_regex , 'W' ) - 1 , 1 ) 87endf 88 89if ! exists ( "no_plugin_maps" ) && ! exists ( "no_context_maps" ) 90" Reflow paragraphs with commands like gqtp ("gq TeX paragraph") 91onoremap <silent><buffer> tp :< c-u > call< sid > tp()< cr > 92" Select TeX paragraph 93vnoremap <silent><buffer> tp< esc > :< c-u > call< sid > tp()< cr > 94 95" $...$ text object 96onoremap <silent><buffer> i$ :< c-u > normal! T$vt$< cr > 97onoremap <silent><buffer> a$ :< c-u > normal! F$vf$< cr > 98vnoremap <buffer> i$ T$ot$ 99vnoremap <buffer> a$ F$of$ 100 101let b: undo_ftplugin .= " | sil! exe 'ounmap <buffer> tp' | sil! exe 'vunmap <buffer> tp'" . 102 \" | sil! exe 'ounmap <buffer> i$' | sil! exe 'vunmap <buffer> i$'" . 103 \" | sil! exe 'ounmap <buffer> a$' | sil! exe 'vunmap <buffer> a$'" 104endif 105endif 106 107if ! exists ( 'current_compiler' ) 108let b: undo_ftplugin ..= "| compiler make" 109compiler context 110endif 111 112let b: undo_ftplugin ..= "| sil! delc -buffer ConTeXt | sil! delc -buffer ConTeXtLog | sil! delc -buffer ConTeXtJobStatus | sil! delc -buffer ConTeXtStopJobs" 113" Commands for asynchronous typesetting 114command ! -buffer -nargs = ? -complete = file ConTeXt call context#typeset(<q-args>) 115command ! -nargs = 0 ConTeXtJobStatus call context#job_status() 116command ! -nargs = 0 ConTeXtStopJobs call context#stop_jobs() 117 118let & cpo = s: cpo_save 119unlet s: cpo_save