annotate runtime/ftplugin/context.vim @ 29756:2acb87ee55fc

Update runtime files Commit: https://github.com/vim/vim/commit/e1f3fd1d02e3f5fe6d2b6d82687c6846b8e500f8 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 15 18:51:32 2022 +0100 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Mon, 15 Aug 2022 20:00:05 +0200
parents 3b34837f4538
children d81556766132
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
1 vim9script
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
2
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
3 # Vim filetype plugin file
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
4 # Language: ConTeXt typesetting engine
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
5 # Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
6 # Former Maintainers: Nikolai Weibull <now@bitwi.se>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
7 # Latest Revision: 2022 Aug 12
375
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
8
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
9 if exists("b:did_ftplugin")
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
10 finish
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
11 endif
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
12
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
13 import autoload '../autoload/context.vim'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
14
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
15 b:did_ftplugin = 1
375
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
16
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
17 if !exists('current_compiler')
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
18 compiler context
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
19 endif
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
20
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
21 b:undo_ftplugin = "setl com< cms< def< inc< sua< fo< ofu<"
375
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
22
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
23 setlocal comments=b:%D,b:%C,b:%M,:%
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
24 setlocal commentstring=%\ %s
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
25 setlocal formatoptions+=tjcroql2
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
26 setlocal omnifunc=context.Complete
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
27 setlocal suffixesadd=.tex,.mkxl,.mkvi,.mkiv,.mkii
375
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
28
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
29 &l:define = '\\\%([egx]\|char\|mathchar\|count\|dimen\|muskip\|skip\|toks\)\='
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
30 .. 'def\|\\font\|\\\%(future\)\=let'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
31 .. '\|\\new\%(count\|dimen\|skip\|muskip\|box\|toks\|read\|write'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
32 .. '\|fam\|insert\|if\)'
375
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
33
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
34 &l:include = '^\s*\\\%(input\|component\|product\|project\|environment\)'
375
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
35
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
36 if exists("g:loaded_matchit") && !exists("b:match_words")
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
37 b:match_ignorecase = 0
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
38 b:match_skip = 'r:\\\@<!\%(\\\\\)*%'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
39 b:match_words = '(:),\[:],{:},\\(:\\),\\\[:\\],\\start\(\a\+\):\\stop\1'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
40 b:undo_ftplugin ..= "| unlet! b:match_ignorecase b:match_words b:match_skip"
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 839
diff changeset
41 endif
375
f14cbd913415 updated for version 7.0097
vimboss
parents:
diff changeset
42
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
43 if !get(g:, 'no_context_maps', 0) && !get(g:, 'no_plugin_maps', 0)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
44 const context_regex = {
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
45 'beginsection': '\\\%(start\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>',
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
46 'endsection': '\\\%(stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>',
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
47 'beginblock': '\\\%(start\|setup\|define\)',
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
48 'endblock': '\\\%(stop\|setup\|define\)',
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
49 }
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
50
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
51 def UndoMap(mapping: string, modes: string)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
52 for mode in modes
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
53 b:undo_ftplugin ..= printf(" | silent! execute '%sunmap <buffer> %s'", mode, mapping)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
54 endfor
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
55 enddef
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
56
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
57 def MoveAround(count: number, what: string, flags: string)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
58 search(context_regex[what], flags .. 's') # 's' sets previous context mark
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
59 var i = 2
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
60 while i <= count
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
61 search(context_regex[what], flags)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
62 i += 1
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
63 endwhile
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
64 enddef
25973
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10319
diff changeset
65
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
66 # Macros to move around
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
67 nnoremap <silent><buffer> [[ <scriptcmd>MoveAround(v:count1, "beginsection", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
68 vnoremap <silent><buffer> [[ <scriptcmd>MoveAround(v:count1, "beginsection", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
69 nnoremap <silent><buffer> ]] <scriptcmd>MoveAround(v:count1, "beginsection", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
70 vnoremap <silent><buffer> ]] <scriptcmd>MoveAround(v:count1, "beginsection", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
71 nnoremap <silent><buffer> [] <scriptcmd>MoveAround(v:count1, "endsection", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
72 vnoremap <silent><buffer> [] <scriptcmd>MoveAround(v:count1, "endsection", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
73 nnoremap <silent><buffer> ][ <scriptcmd>MoveAround(v:count1, "endsection", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
74 vnoremap <silent><buffer> ][ <scriptcmd>MoveAround(v:count1, "endsection", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
75 nnoremap <silent><buffer> [{ <scriptcmd>MoveAround(v:count1, "beginblock", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
76 vnoremap <silent><buffer> [{ <scriptcmd>MoveAround(v:count1, "beginblock", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
77 nnoremap <silent><buffer> ]} <scriptcmd>MoveAround(v:count1, "endblock", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
78 vnoremap <silent><buffer> ]} <scriptcmd>MoveAround(v:count1, "endblock", "W") <cr>
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
79
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
80 for mapping in ['[[', ']]', '[]', '][', '[{', ']}']
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
81 UndoMap(mapping, 'nv')
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
82 endfor
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
83
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
84 # Other useful mappings
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
85 const tp_regex = '?^$\|^\s*\\\(item\|start\|stop\|blank\|\%(sub\)*section\|chapter\|\%(sub\)*subject\|title\|part\)'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
86
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
87 def TeXPar()
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
88 cursor(search(tp_regex, 'bcW') + 1, 1)
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
89 normal! V
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
90 cursor(search(tp_regex, 'W') - 1, 1)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
91 enddef
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
92
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
93 # Reflow paragraphs with mappings like gqtp ("gq TeX paragraph")
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
94 onoremap <silent><buffer> tp <scriptcmd>TeXPar()<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
95 # Select TeX paragraph
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
96 vnoremap <silent><buffer> tp <scriptcmd>TeXPar()<cr>
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
97
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
98 # $...$ text object
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
99 onoremap <silent><buffer> i$ <scriptcmd>normal! T$vt$<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
100 onoremap <silent><buffer> a$ <scriptcmd>normal! F$vf$<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
101 vnoremap <buffer> i$ T$ot$
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
102 vnoremap <buffer> a$ F$of$
25973
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10319
diff changeset
103
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
104 for mapping in ['tp', 'i$', 'a$']
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
105 UndoMap(mapping, 'ov')
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
106 endfor
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
107 endif
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
108
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
109 # Commands for asynchronous typesetting
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
110 command! -buffer -nargs=? -complete=buffer ConTeXt context.Typeset(<q-args>)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
111 command! -buffer -nargs=0 ConTeXtLog context.Log('%')
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
112 command! -nargs=0 ConTeXtJobStatus context.JobStatus()
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
113 command! -nargs=0 ConTeXtStopJobs context.StopJobs()
10301
07d2b5a3b7cc commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
114
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25973
diff changeset
115 # vim: sw=2 fdm=marker