Mercurial > vim
annotate runtime/ftplugin/mf.vim @ 31430:e5e95e8c78a7
Update runtime files
Commit: https://github.com/vim/vim/commit/7db29e4b5c3a347d24ca5062ddaa5cf4c4d54b9c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 11 15:53:04 2022 +0000
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 11 Dec 2022 17:00:05 +0100 |
parents | 2acb87ee55fc |
children | 8ae680be2a51 |
rev | line source |
---|---|
29756 | 1 vim9script |
2 | |
3 # Vim filetype plugin file | |
4 # Language: METAFONT | |
5 # Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com> | |
6 # Former Maintainers: Nikolai Weibull <now@bitwi.se> | |
7 # Latest Revision: 2022 Aug 12 | |
7 | 8 |
9 if exists("b:did_ftplugin") | |
10 finish | |
11 endif | |
12 | |
29756 | 13 b:did_ftplugin = 1 |
14 b:undo_ftplugin = "setl com< cms< fo< sua< inc< def< ofu<" | |
1698 | 15 |
29756 | 16 setlocal comments=:% |
17 setlocal commentstring=%\ %s | |
18 setlocal formatoptions+=cjroql2 | |
19 setlocal formatoptions-=t | |
20 setlocal omnifunc=syntaxcomplete#Complete | |
10244
876fbdd84e52
commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents:
1698
diff
changeset
|
21 setlocal suffixesadd=.mf |
876fbdd84e52
commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents:
1698
diff
changeset
|
22 |
29756 | 23 &l:include = '\<input\>' |
24 &l:define = '\<\%(let\|newinternal\|interim\|def\|vardef\)\>\|\<\%(primary\|secondary\|tertiary\)def\>\s*[^ .]\+' | |
389 | 25 |
29756 | 26 g:omni_syntax_group_include_mf = 'mf\w\+' |
27 g:omni_syntax_group_exclude_mf = 'mfTodoComment' | |
10244
876fbdd84e52
commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents:
1698
diff
changeset
|
28 |
29756 | 29 if exists("g:loaded_matchit") && !exists("b:match_words") |
30 b:match_ignorecase = 0 | |
31 b:match_skip = 'synIDattr(synID(line("."), col("."), 1), "name") =~# "mf\\(Comment\\|String\\)$"' | |
32 b:match_words = '\<if\>:\<else\%[if]\>:\<fi\>,' | |
33 .. '\<for\%(\|suffixes\|ever\)\>:\<exit\%(if\|unless\)\>:\<endfor\>,' | |
34 .. '\<\%(\|var\|primary\|secondary\|tertiary\)def\>:\<enddef\>,' | |
35 .. '\<begingroup\>:\<endgroup\>,' | |
36 .. '\<begin\%(logo\)\?char\>:\<endchar\>' | |
37 b:undo_ftplugin ..= "| unlet! b:match_ignorecase b:match_words b:match_skip" | |
10244
876fbdd84e52
commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents:
1698
diff
changeset
|
38 endif |
389 | 39 |
29756 | 40 if !get(g:, 'no_mf_maps', 0) && !get(g:, 'no_plugin_maps', 0) |
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 |