annotate runtime/ftplugin/mf.vim @ 34146:23bb675796f0 v9.1.0034

patch 9.1.0034: Window scrolls unexpectedly when 'scrollbind' is set Commit: https://github.com/vim/vim/commit/ac4cffc6d9d307778d8a2945adab70244470bbb8 Author: Christian Brabandt <cb@256bit.org> Date: Tue Jan 16 17:22:38 2024 +0100 patch 9.1.0034: Window scrolls unexpectedly when 'scrollbind' is set Problem: Window may unexpectedly scroll when 'scrollbind' is set and setting a buffer-local option using setbufvar() (Boris Staletic) Solution: Save and restore the windows topline before opening the popup window. fixes: #13863 closes: #13869 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 16 Jan 2024 17:30:10 +0100
parents 8ae680be2a51
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
1 vim9script
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
2
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
3 # Vim filetype plugin file
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
4 # Language: METAFONT
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
5 # Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
6 # Former Maintainers: Nikolai Weibull <now@bitwi.se>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
7 # Latest Revision: 2022 Aug 12
34134
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 29756
diff changeset
8 # 2024 Jan 14 by Vim Project (browsefilter)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 if exists("b:did_ftplugin")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
14 b:did_ftplugin = 1
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
15 b:undo_ftplugin = "setl com< cms< fo< sua< inc< def< ofu<"
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 839
diff changeset
16
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
17 setlocal comments=:%
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
18 setlocal commentstring=%\ %s
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
19 setlocal formatoptions+=cjroql2
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
20 setlocal formatoptions-=t
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
21 setlocal omnifunc=syntaxcomplete#Complete
10244
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
22 setlocal suffixesadd=.mf
876fbdd84e52 commit https://github.com/vim/vim/commit/2ec618c9feac4573b154510236ad8121c77d0eca
Christian Brabandt <cb@256bit.org>
parents: 1698
diff changeset
23
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
24 &l:include = '\<input\>'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
25 &l:define = '\<\%(let\|newinternal\|interim\|def\|vardef\)\>\|\<\%(primary\|secondary\|tertiary\)def\>\s*[^ .]\+'
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
26
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
27 g:omni_syntax_group_include_mf = 'mf\w\+'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
28 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
29
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
30 if exists("g:loaded_matchit") && !exists("b:match_words")
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
31 b:match_ignorecase = 0
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
32 b:match_skip = 'synIDattr(synID(line("."), col("."), 1), "name") =~# "mf\\(Comment\\|String\\)$"'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
33 b:match_words = '\<if\>:\<else\%[if]\>:\<fi\>,'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
34 .. '\<for\%(\|suffixes\|ever\)\>:\<exit\%(if\|unless\)\>:\<endfor\>,'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
35 .. '\<\%(\|var\|primary\|secondary\|tertiary\)def\>:\<enddef\>,'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
36 .. '\<begingroup\>:\<endgroup\>,'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
37 .. '\<begin\%(logo\)\?char\>:\<endchar\>'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
38 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
39 endif
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 7
diff changeset
40
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
41 if !get(g:, 'no_mf_maps', 0) && !get(g:, 'no_plugin_maps', 0)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
42 const mf_regex = {
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
43 'beginsection': '^\s*\%(\%(\|var\|primary\|secondary\|tertiary\)def\|beginchar\|beginlogochar\)\>',
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
44 'endsection': '^\s*\%(enddef\|endchar\)\>',
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
45 'beginblock': '^\s*\%(begingroup\|if\|for\%(\|suffixes\|ever\)\)\>',
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
46 'endblock': '^\s*\%(endgroup\|fi\|endfor\)\>'}
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
47
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
48 def MoveAround(count: number, what: string, flags: string)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
49 search(mf_regex[what], flags .. 's') # 's' sets previous context mark
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
50 var i = 2
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
51 while i <= count
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
52 search(mf_regex[what], flags)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
53 i += 1
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
54 endwhile
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
55 enddef
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
56
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
57 # Macros to move around
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
58 nnoremap <silent><buffer> [[ <scriptcmd>MoveAround(v:count1, "beginsection", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
59 vnoremap <silent><buffer> [[ <scriptcmd>MoveAround(v:count1, "beginsection", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
60 nnoremap <silent><buffer> ]] <scriptcmd>MoveAround(v:count1, "beginsection", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
61 vnoremap <silent><buffer> ]] <scriptcmd>MoveAround(v:count1, "beginsection", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
62 nnoremap <silent><buffer> [] <scriptcmd>MoveAround(v:count1, "endsection", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
63 vnoremap <silent><buffer> [] <scriptcmd>MoveAround(v:count1, "endsection", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
64 nnoremap <silent><buffer> ][ <scriptcmd>MoveAround(v:count1, "endsection", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
65 vnoremap <silent><buffer> ][ <scriptcmd>MoveAround(v:count1, "endsection", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
66 nnoremap <silent><buffer> [{ <scriptcmd>MoveAround(v:count1, "beginblock", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
67 vnoremap <silent><buffer> [{ <scriptcmd>MoveAround(v:count1, "beginblock", "bW")<cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
68 nnoremap <silent><buffer> ]} <scriptcmd>MoveAround(v:count1, "endblock", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
69 vnoremap <silent><buffer> ]} <scriptcmd>MoveAround(v:count1, "endblock", "W") <cr>
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
70
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
71 for mapping in ["[[", "]]", "[]", "][", "[{", "]}"]
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
72 b:undo_ftplugin ..= printf(" | silent! execute 'nunmap <buffer> %s'", mapping)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
73 b:undo_ftplugin ..= printf(" | silent! execute 'vunmap <buffer> %s'", mapping)
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
74 endfor
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
75 endif
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
76
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
77 if (has('gui_win32') || has('gui_gtk')) && !exists('b:browsefilter')
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
78 b:browsefilter = "METAFONT Source Files (*.mf)\t*.mf\n"
34134
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 29756
diff changeset
79 if has("win32")
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 29756
diff changeset
80 b:browsefilter ..= "All Files (*.*)\t*\n"
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 29756
diff changeset
81 else
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 29756
diff changeset
82 b:browsefilter ..= "All Files (*)\t*\n"
8ae680be2a51 runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents: 29756
diff changeset
83 endif
29756
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
84 b:undo_ftplugin ..= ' | unlet! b:browsefilter'
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
85 endif
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
86
2acb87ee55fc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10261
diff changeset
87 # vim: sw=2 fdm=marker