annotate runtime/ftplugin/mp.vim @ 19872:8a7bede7b138 v8.2.0492

patch 8.2.0492: Vim9: some error messages not tested Commit: https://github.com/vim/vim/commit/a8c1770469504ae66c80bbdb03b6b31641215848 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Apr 1 21:17:24 2020 +0200 patch 8.2.0492: Vim9: some error messages not tested Problem: Vim9: some error messages not tested. Solution: Add more tests. Remove dead code. Fix uncovered bugs.
author Bram Moolenaar <Bram@vim.org>
date Wed, 01 Apr 2020 21:30:03 +0200
parents bdd7fc1a38c0
children 2acb87ee55fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
1 " Vim filetype plugin file
10244
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
2 " Language: MetaPost
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
3 " Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
4 " Former Maintainers: Nikolai Weibull <now@bitwi.se>
10261
bdd7fc1a38c0 commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents: 10244
diff changeset
5 " Latest Revision: 2016 Oct 2
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
6
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
7 if exists("b:did_ftplugin")
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
8 finish
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
9 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
10 let b:did_ftplugin = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1217
diff changeset
12 let s:cpo_save = &cpo
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1217
diff changeset
13 set cpo&vim
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1217
diff changeset
14
10244
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
15 let b:undo_ftplugin = "setl com< cms< fo< sua< inc< def< ofu<"
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
16 \ . "| unlet! b:match_ignorecase b:match_words b:match_skip"
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
17
10244
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
18 setlocal comments=:% commentstring=%\ %s formatoptions-=t formatoptions+=cjroql2
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
19 setlocal suffixesadd=.mp,.mpiv
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
20 let &l:include = '\<\%(input\|loadmodule\)\>' " loadmodule is in MetaFun
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
21 let &l:define = '\<\%(let\|newinternal\|interim\|def\|vardef\)\>\|\<\%(primary\|secondary\|tertiary\)def\>\s*[^ .]\+'
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
22 setlocal omnifunc=syntaxcomplete#Complete
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
23 let g:omni_syntax_group_include_mp = 'mf\w\+,mp\w\+'
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
24 let g:omni_syntax_group_exclude_mp = 'mfTodoComment'
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
25
1217
82274b284600 updated for version 7.1b
vimboss
parents: 839
diff changeset
26 if exists(":FixBeginfigs") != 2
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
27 command -nargs=0 FixBeginfigs call s:fix_beginfigs()
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
28
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
29 function! s:fix_beginfigs()
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
30 let i = 1
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
31 g/^beginfig(\d*);$/s//\='beginfig('.i.');'/ | let i = i + 1
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
32 endfunction
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
33 endif
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1217
diff changeset
34
10244
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
35 let s:mp_regex = {
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
36 \ 'beginsection' : '^\s*\%(\%(\|var\|primary\|secondary\|tertiary\)def\|begin\%(fig\|char\|logochar\|glyph\|graph\)\)\>',
10261
bdd7fc1a38c0 commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents: 10244
diff changeset
37 \ 'endsection' : '^\s*\%(enddef\|end\%(fig\|char\|glyph\|graph\)\)\>',
10244
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
38 \ 'beginblock' : '^\s*\%(begingroup\|if\|for\%(\|suffixes\|ever\)\)\>',
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
39 \ 'endblock' : '^\s*\%(endgroup\|fi\|endfor\)\>'
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
40 \ }
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
41
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
42 function! s:move_around(count, what, flags, visual)
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
43 if a:visual
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
44 exe "normal! gv"
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
45 endif
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
46 call search(s:mp_regex[a:what], a:flags.'s') " 's' sets previous context mark
10261
bdd7fc1a38c0 commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents: 10244
diff changeset
47 call map(range(2, a:count), 'search(s:mp_regex[a:what], a:flags)')
10244
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
48 endfunction
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
49
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
50
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
51 " Move around macros.
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
52 nnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:false) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
53 vnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:true) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
54 nnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:false) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
55 vnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:true) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
56 nnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:false) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
57 vnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:true) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
58 nnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:false) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
59 vnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:true) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
60 nnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:false) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
61 vnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:true) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
62 nnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:false) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
63 vnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:true) <CR>
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
64
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
65 if exists("loaded_matchit")
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
66 let b:match_ignorecase = 0
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
67 let b:match_words =
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
68 \ '\<if\>:\<else\%[if]\>:\<fi\>,' .
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
69 \ '\<for\%(\|suffixes\|ever\)\>:\<exit\%(if\|unless\)\>:\<endfor\>,' .
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
70 \ '\<\%(\|var\|primary\|secondary\|tertiary\)def\>:\<enddef\>,' .
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
71 \ '\<beginfig\>:\<endfig\>,' .
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
72 \ '\<begingroup\>:\<endgroup\>,' .
10261
bdd7fc1a38c0 commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents: 10244
diff changeset
73 \ '\<begin\%(logo\)\?char\>:\<endchar\>,' .
bdd7fc1a38c0 commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents: 10244
diff changeset
74 \ '\<beginglyph\>:\<endglyph\>,' .
10244
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
75 \ '\<begingraph\>:\<endgraph\>'
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
76 " Ignore comments and strings
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
77 let b:match_skip = 'synIDattr(synID(line("."), col("."), 1), "name")
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
78 \ =~# "^mf\\%(Comment\\|String\\|\\)$\\|^mpTeXinsert$"'
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
79 endif
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
80
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1217
diff changeset
81 let &cpo = s:cpo_save
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1217
diff changeset
82 unlet s:cpo_save