comparison runtime/ftplugin/mf.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 bdd7fc1a38c0
children 8ae680be2a51
comparison
equal deleted inserted replaced
29755:e726ee71b93b 29756:2acb87ee55fc
1 " Vim filetype plugin file 1 vim9script
2 " Language: METAFONT 2
3 " Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com> 3 # Vim filetype plugin file
4 " Former Maintainers: Nikolai Weibull <now@bitwi.se> 4 # Language: METAFONT
5 " Latest Revision: 2016 Oct 2 5 # Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
6 # Former Maintainers: Nikolai Weibull <now@bitwi.se>
7 # Latest Revision: 2022 Aug 12
6 8
7 if exists("b:did_ftplugin") 9 if exists("b:did_ftplugin")
8 finish 10 finish
9 endif 11 endif
10 let b:did_ftplugin = 1
11 12
12 let s:cpo_save = &cpo 13 b:did_ftplugin = 1
13 set cpo&vim 14 b:undo_ftplugin = "setl com< cms< fo< sua< inc< def< ofu<"
14 15
15 let b:undo_ftplugin = "setl com< cms< fo< sua< inc< def< ofu<" 16 setlocal comments=:%
16 \ . "| unlet! b:match_ignorecase b:match_words b:match_skip" 17 setlocal commentstring=%\ %s
18 setlocal formatoptions+=cjroql2
19 setlocal formatoptions-=t
20 setlocal omnifunc=syntaxcomplete#Complete
21 setlocal suffixesadd=.mf
17 22
18 setlocal comments=:% commentstring=%\ %s formatoptions-=t formatoptions+=cjroql2 23 &l:include = '\<input\>'
19 setlocal suffixesadd=.mf 24 &l:define = '\<\%(let\|newinternal\|interim\|def\|vardef\)\>\|\<\%(primary\|secondary\|tertiary\)def\>\s*[^ .]\+'
20 let &l:include = '\<input\>'
21 let &l:define = '\<\%(let\|newinternal\|interim\|def\|vardef\)\>\|\<\%(primary\|secondary\|tertiary\)def\>\s*[^ .]\+'
22 setlocal omnifunc=syntaxcomplete#Complete
23 let g:omni_syntax_group_include_mf = 'mf\w\+'
24 let g:omni_syntax_group_exclude_mf = 'mfTodoComment'
25 25
26 let s:mp_regex = { 26 g:omni_syntax_group_include_mf = 'mf\w\+'
27 \ 'beginsection' : '^\s*\%(\%(\|var\|primary\|secondary\|tertiary\)def\|beginchar\|beginlogochar\)\>', 27 g:omni_syntax_group_exclude_mf = 'mfTodoComment'
28 \ 'endsection' : '^\s*\%(enddef\|endchar\)\>',
29 \ 'beginblock' : '^\s*\%(begingroup\|if\|for\%(\|suffixes\|ever\)\)\>',
30 \ 'endblock' : '^\s*\%(endgroup\|fi\|endfor\)\>'
31 \ }
32 28
33 function! s:move_around(count, what, flags, visual) 29 if exists("g:loaded_matchit") && !exists("b:match_words")
34 if a:visual 30 b:match_ignorecase = 0
35 exe "normal! gv" 31 b:match_skip = 'synIDattr(synID(line("."), col("."), 1), "name") =~# "mf\\(Comment\\|String\\)$"'
36 endif 32 b:match_words = '\<if\>:\<else\%[if]\>:\<fi\>,'
37 call search(s:mp_regex[a:what], a:flags.'s') " 's' sets previous context mark 33 .. '\<for\%(\|suffixes\|ever\)\>:\<exit\%(if\|unless\)\>:\<endfor\>,'
38 call map(range(2, a:count), 'search(s:mp_regex[a:what], a:flags)') 34 .. '\<\%(\|var\|primary\|secondary\|tertiary\)def\>:\<enddef\>,'
39 endfunction 35 .. '\<begingroup\>:\<endgroup\>,'
40 36 .. '\<begin\%(logo\)\?char\>:\<endchar\>'
41 37 b:undo_ftplugin ..= "| unlet! b:match_ignorecase b:match_words b:match_skip"
42 " Move around macros.
43 nnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:false) <CR>
44 vnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:true) <CR>
45 nnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:false) <CR>
46 vnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:true) <CR>
47 nnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:false) <CR>
48 vnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:true) <CR>
49 nnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:false) <CR>
50 vnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:true) <CR>
51 nnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:false) <CR>
52 vnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:true) <CR>
53 nnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:false) <CR>
54 vnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:true) <CR>
55
56 if exists("loaded_matchit")
57 let b:match_ignorecase = 0
58 let b:match_words =
59 \ '\<if\>:\<else\%[if]\>:\<fi\>,' .
60 \ '\<for\%(\|suffixes\|ever\)\>:\<exit\%(if\|unless\)\>:\<endfor\>,' .
61 \ '\<\%(\|var\|primary\|secondary\|tertiary\)def\>:\<enddef\>,' .
62 \ '\<begingroup\>:\<endgroup\>,' .
63 \ '\<begin\%(logo\)\?char\>:\<endchar\>'
64 " Ignore comments and strings
65 let b:match_skip = 'synIDattr(synID(line("."), col("."), 1), "name")
66 \ =~# "mf\\(Comment\\|String\\)$"'
67 endif 38 endif
68 39
69 let &cpo = s:cpo_save 40 if !get(g:, 'no_mf_maps', 0) && !get(g:, 'no_plugin_maps', 0)
70 unlet s:cpo_save 41 const mf_regex = {
42 'beginsection': '^\s*\%(\%(\|var\|primary\|secondary\|tertiary\)def\|beginchar\|beginlogochar\)\>',
43 'endsection': '^\s*\%(enddef\|endchar\)\>',
44 'beginblock': '^\s*\%(begingroup\|if\|for\%(\|suffixes\|ever\)\)\>',
45 'endblock': '^\s*\%(endgroup\|fi\|endfor\)\>'}
46
47 def MoveAround(count: number, what: string, flags: string)
48 search(mf_regex[what], flags .. 's') # 's' sets previous context mark
49 var i = 2
50 while i <= count
51 search(mf_regex[what], flags)
52 i += 1
53 endwhile
54 enddef
55
56 # Macros to move around
57 nnoremap <silent><buffer> [[ <scriptcmd>MoveAround(v:count1, "beginsection", "bW")<cr>
58 vnoremap <silent><buffer> [[ <scriptcmd>MoveAround(v:count1, "beginsection", "bW")<cr>
59 nnoremap <silent><buffer> ]] <scriptcmd>MoveAround(v:count1, "beginsection", "W") <cr>
60 vnoremap <silent><buffer> ]] <scriptcmd>MoveAround(v:count1, "beginsection", "W") <cr>
61 nnoremap <silent><buffer> [] <scriptcmd>MoveAround(v:count1, "endsection", "bW")<cr>
62 vnoremap <silent><buffer> [] <scriptcmd>MoveAround(v:count1, "endsection", "bW")<cr>
63 nnoremap <silent><buffer> ][ <scriptcmd>MoveAround(v:count1, "endsection", "W") <cr>
64 vnoremap <silent><buffer> ][ <scriptcmd>MoveAround(v:count1, "endsection", "W") <cr>
65 nnoremap <silent><buffer> [{ <scriptcmd>MoveAround(v:count1, "beginblock", "bW")<cr>
66 vnoremap <silent><buffer> [{ <scriptcmd>MoveAround(v:count1, "beginblock", "bW")<cr>
67 nnoremap <silent><buffer> ]} <scriptcmd>MoveAround(v:count1, "endblock", "W") <cr>
68 vnoremap <silent><buffer> ]} <scriptcmd>MoveAround(v:count1, "endblock", "W") <cr>
69
70 for mapping in ["[[", "]]", "[]", "][", "[{", "]}"]
71 b:undo_ftplugin ..= printf(" | silent! execute 'nunmap <buffer> %s'", mapping)
72 b:undo_ftplugin ..= printf(" | silent! execute 'vunmap <buffer> %s'", mapping)
73 endfor
74 endif
75
76 if (has('gui_win32') || has('gui_gtk')) && !exists('b:browsefilter')
77 b:browsefilter = "METAFONT Source Files (*.mf)\t*.mf\n"
78 .. "All Files (*.*)\t*.*\n"
79 b:undo_ftplugin ..= ' | unlet! b:browsefilter'
80 endif
81
82 # vim: sw=2 fdm=marker