comparison runtime/ftplugin/context.vim @ 10301:07d2b5a3b7cc

commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 23 21:21:08 2016 +0200 Updated runtime files.
author Christian Brabandt <cb@256bit.org>
date Sun, 23 Oct 2016 21:30:06 +0200
parents f4f8014d516e
children 169a62d5bcb9
comparison
equal deleted inserted replaced
10300:1888d5ca413c 10301:07d2b5a3b7cc
1 " Vim filetype plugin file 1 " Vim filetype plugin file
2 " Language: ConTeXt typesetting engine 2 " Language: ConTeXt typesetting engine
3 " Maintainer: Nikolai Weibull <now@bitwi.se> 3 " Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
4 " Latest Revision: 2008-07-09 4 " Former Maintainers: Nikolai Weibull <now@bitwi.se>
5 " Latest Revision: 2016 Oct 14
5 6
6 if exists("b:did_ftplugin") 7 if exists("b:did_ftplugin")
7 finish 8 finish
8 endif 9 endif
9 let b:did_ftplugin = 1 10 let b:did_ftplugin = 1
10 11
11 let s:cpo_save = &cpo 12 let s:cpo_save = &cpo
12 set cpo&vim 13 set cpo&vim
13 14
14 let b:undo_ftplugin = "setl com< cms< def< inc< sua< fo<" 15 if !exists('current_compiler')
16 compiler context
17 endif
15 18
16 setlocal comments=b:%D,b:%C,b:%M,:% commentstring=%\ %s formatoptions+=tcroql 19 let b:undo_ftplugin = "setl com< cms< def< inc< sua< fo< ofu<"
20 \ . "| unlet! b:match_ignorecase b:match_words b:match_skip"
21
22 setlocal comments=b:%D,b:%C,b:%M,:% commentstring=%\ %s formatoptions+=tjcroql2
23 if get(b:, 'context_metapost', get(g:, 'context_metapost', 1))
24 setlocal omnifunc=context#complete
25 let g:omni_syntax_group_include_context = 'mf\w\+,mp\w\+'
26 let g:omni_syntax_group_exclude_context = 'mfTodoComment'
27 endif
17 28
18 let &l:define='\\\%([egx]\|char\|mathchar\|count\|dimen\|muskip\|skip\|toks\)\=' 29 let &l:define='\\\%([egx]\|char\|mathchar\|count\|dimen\|muskip\|skip\|toks\)\='
19 \ . 'def\|\\font\|\\\%(future\)\=let' 30 \ . 'def\|\\font\|\\\%(future\)\=let'
20 \ . '\|\\new\%(count\|dimen\|skip\|muskip\|box\|toks\|read\|write' 31 \ . '\|\\new\%(count\|dimen\|skip\|muskip\|box\|toks\|read\|write'
21 \ . '\|fam\|insert\|if\)' 32 \ . '\|fam\|insert\|if\)'
22 33
23 let &l:include = '^\s*\%(input\|component\)' 34 let &l:include = '^\s*\\\%(input\|component\|product\|project\|environment\)'
24 35
25 setlocal suffixesadd=.tex 36 setlocal suffixesadd=.tex
26 37
27 if exists("loaded_matchit") 38 if exists("loaded_matchit")
28 let b:match_ignorecase = 0 39 let b:match_ignorecase = 0
29 let b:match_skip = 'r:\\\@<!\%(\\\\\)*%' 40 let b:match_skip = 'r:\\\@<!\%(\\\\\)*%'
30 let b:match_words = '(:),\[:],{:},\\(:\\),\\\[:\\],' . 41 let b:match_words = '(:),\[:],{:},\\(:\\),\\\[:\\],' .
31 \ '\\start\(\a\+\):\\stop\1' 42 \ '\\start\(\a\+\):\\stop\1'
32 endif 43 endif
33 44
45 let s:context_regex = {
46 \ 'beginsection' : '\\\%(start\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>',
47 \ 'endsection' : '\\\%(stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>',
48 \ 'beginblock' : '\\\%(start\|setup\|define\)',
49 \ 'endblock' : '\\\%(stop\|setup\|define\)'
50 \ }
51
52 function! s:move_around(count, what, flags, visual)
53 if a:visual
54 exe "normal! gv"
55 endif
56 call search(s:context_regex[a:what], a:flags.'s') " 's' sets previous context mark
57 call map(range(2, a:count), 'search(s:context_regex[a:what], a:flags)')
58 endfunction
59
60 " Move around macros.
61 nnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:false) <CR>
62 vnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:true) <CR>
63 nnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:false) <CR>
64 vnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:true) <CR>
65 nnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:false) <CR>
66 vnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:true) <CR>
67 nnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:false) <CR>
68 vnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:true) <CR>
69 nnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:false) <CR>
70 vnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:true) <CR>
71 nnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:false) <CR>
72 vnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:true) <CR>
73
74 " Other useful mappings
75 if get(g:, 'context_mappings', 1)
76 let s:tp_regex = '?^$\|^\s*\\\(item\|start\|stop\|blank\|\%(sub\)*section\|chapter\|\%(sub\)*subject\|title\|part\)'
77
78 fun! s:tp()
79 call cursor(search(s:tp_regex, 'bcW') + 1, 1)
80 normal! V
81 call cursor(search(s:tp_regex, 'W') - 1, 1)
82 endf
83
84 " Reflow paragraphs with commands like gqtp ("gq TeX paragraph")
85 onoremap <silent><buffer> tp :<c-u>call <sid>tp()<cr>
86 " Select TeX paragraph
87 vnoremap <silent><buffer> tp <esc>:<c-u>call <sid>tp()<cr>
88
89 " $...$ text object
90 onoremap <silent><buffer> i$ :<c-u>normal! T$vt$<cr>
91 onoremap <silent><buffer> a$ :<c-u>normal! F$vf$<cr>
92 vnoremap <buffer> i$ T$ot$
93 vnoremap <buffer> a$ F$of$
94 endif
95
96 " Commands for asynchronous typesetting
97 command! -buffer -nargs=? -complete=file ConTeXt call context#typeset(<q-args>)
98 command! -nargs=0 ConTeXtJobStatus call context#job_status()
99 command! -nargs=0 ConTeXtStopJobs call context#stop_jobs()
100
34 let &cpo = s:cpo_save 101 let &cpo = s:cpo_save
35 unlet s:cpo_save 102 unlet s:cpo_save