codekingpro/portable-devtools
114k
1vim9script2 3# Vim filetype plugin file4# Language: METAFONT5# Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>6# Former Maintainers: Nikolai Weibull <now@bitwi.se>7# Latest Revision: 2026 Jan 108 9if exists("b:did_ftplugin")10 finish11endif12 13b:did_ftplugin = 114b:undo_ftplugin = "setl com< cms< fo< sua< inc< def< ofu<"15 16setlocal comments=:%17setlocal commentstring=%\ %s18setlocal formatoptions+=cjroql219setlocal formatoptions-=t20setlocal omnifunc=syntaxcomplete#Complete21setlocal suffixesadd=.mf22 23&l:include = '\<input\>'24&l:define = '\<\%(let\|newinternal\|interim\|def\|vardef\)\>\|\<\%(primary\|secondary\|tertiary\)def\>\s*[^ .]\+'25 26g:omni_syntax_group_include_mf = 'mf\w\+'27g:omni_syntax_group_exclude_mf = 'mfTodoComment'28 29if exists("g:loaded_matchit") && !exists("b:match_words")30 b:match_ignorecase = 031 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"38endif39 40if !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 mark49 var i = 250 while i <= count51 search(mf_regex[what], flags)52 i += 153 endwhile54 enddef55 56 # Macros to move around57 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 endfor74endif75 76if (has('gui_win32') || has('gui_gtk')) && !exists('b:browsefilter')77 b:browsefilter = "METAFONT Source Files (*.mf)\t*.mf\n"78 if has("win32")79 b:browsefilter ..= "All Files (*.*)\t*\n"80 else81 b:browsefilter ..= "All Files (*)\t*\n"82 endif83 b:undo_ftplugin ..= ' | unlet! b:browsefilter'84endif85 86# vim: sw=2 fdm=marker87 