Mercurial > vim
annotate runtime/ftplugin/vim.vim @ 32543:ca42967a3253 v9.0.1603
patch 9.0.1603: display wrong if scrolling multiple lines with 'smoothscroll'
Commit: https://github.com/vim/vim/commit/3c802277604a6b21110e41bedfe4c937ba7c2b7d
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sat Jun 3 22:08:33 2023 +0100
patch 9.0.1603: display wrong if scrolling multiple lines with 'smoothscroll'
Problem: Display wrong when scrolling multiple lines with 'smoothscroll'
set.
Solution: Redraw when w_skipcol changed. (closes #12477, closes #12468)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 03 Jun 2023 23:15:04 +0200 |
parents | a9b5ffbc0428 |
children | 4027cefc2aab |
rev | line source |
---|---|
7 | 1 " Vim filetype plugin |
2 " Language: Vim | |
3 " Maintainer: Bram Moolenaar <Bram@vim.org> | |
32004 | 4 " Last Change: 2023 Feb 07 |
7 | 5 |
6 " Only do this when not done yet for this buffer | |
7 if exists("b:did_ftplugin") | |
8 finish | |
9 endif | |
10 | |
11 " Don't load another plugin for this buffer | |
12 let b:did_ftplugin = 1 | |
13 | |
2034 | 14 let s:cpo_save = &cpo |
20552 | 15 set cpo&vim |
7 | 16 |
14298
4a588e3afd4a
Update runtime files, add Danish translations.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
17 if !exists('*VimFtpluginUndo') |
4a588e3afd4a
Update runtime files, add Danish translations.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
18 func VimFtpluginUndo() |
29403 | 19 setl fo< isk< com< tw< commentstring< include< define< |
14519 | 20 if exists('b:did_add_maps') |
21 silent! nunmap <buffer> [[ | |
22 silent! vunmap <buffer> [[ | |
23 silent! nunmap <buffer> ]] | |
24 silent! vunmap <buffer> ]] | |
25 silent! nunmap <buffer> [] | |
26 silent! vunmap <buffer> [] | |
27 silent! nunmap <buffer> ][ | |
28 silent! vunmap <buffer> ][ | |
29 silent! nunmap <buffer> ]" | |
30 silent! vunmap <buffer> ]" | |
31 silent! nunmap <buffer> [" | |
32 silent! vunmap <buffer> [" | |
14298
4a588e3afd4a
Update runtime files, add Danish translations.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
33 endif |
4a588e3afd4a
Update runtime files, add Danish translations.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
34 unlet! b:match_ignorecase b:match_words b:match_skip b:did_add_maps |
4a588e3afd4a
Update runtime files, add Danish translations.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
35 endfunc |
4a588e3afd4a
Update runtime files, add Danish translations.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
36 endif |
4a588e3afd4a
Update runtime files, add Danish translations.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
37 |
4a588e3afd4a
Update runtime files, add Danish translations.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
38 let b:undo_ftplugin = "call VimFtpluginUndo()" |
7 | 39 |
40 " Set 'formatoptions' to break comment lines but not other lines, | |
41 " and insert the comment leader when hitting <CR> or using "o". | |
42 setlocal fo-=t fo+=croql | |
43 | |
2034 | 44 " To allow tag lookup via CTRL-] for autoload functions, '#' must be a |
45 " keyword character. E.g., for netrw#Nread(). | |
46 setlocal isk+=# | |
47 | |
12826 | 48 " Use :help to lookup the keyword under the cursor with K. |
49 setlocal keywordprg=:help | |
50 | |
30202 | 51 " Comments starts with # in Vim9 script. We have to guess which one to use. |
23573 | 52 if "\n" .. getline(1, 10)->join("\n") =~# '\n\s*vim9\%[script]\>' |
23666 | 53 setlocal commentstring=#%s |
23573 | 54 else |
23666 | 55 setlocal commentstring=\"%s |
23573 | 56 endif |
57 | |
30202 | 58 " Set 'comments' to format dashed lists in comments, both in Vim9 and legacy |
59 " script. | |
60 setlocal com=sO:#\ -,mO:#\ \ ,eO:##,:#,sO:\"\ -,mO:\"\ \ ,eO:\"\",:\" | |
61 | |
29403 | 62 " set 'include' to recognize import commands |
63 setlocal include=\\v^\\s*import\\s*(autoload)? | |
64 | |
65 " set 'define' to recognize export commands | |
66 setlocal define=\\v^\\s*export\\s*(def\|const\|var\|final) | |
7 | 67 |
68 " Format comments to be up to 78 characters long | |
69 if &tw == 0 | |
70 setlocal tw=78 | |
71 endif | |
72 | |
13051 | 73 if !exists("no_plugin_maps") && !exists("no_vim_maps") |
14298
4a588e3afd4a
Update runtime files, add Danish translations.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
74 let b:did_add_maps = 1 |
4a588e3afd4a
Update runtime files, add Danish translations.
Christian Brabandt <cb@256bit.org>
parents:
13051
diff
changeset
|
75 |
13051 | 76 " Move around functions. |
30547 | 77 nnoremap <silent><buffer> [[ m':call search('^\s*\(fu\%[nction]\\|\(export\s\+\)\?def\)\>', "bW")<CR> |
78 vnoremap <silent><buffer> [[ m':<C-U>exe "normal! gv"<Bar>call search('^\s*\(fu\%[nction]\\|\(export\s\+\)\?def\)\>', "bW")<CR> | |
79 nnoremap <silent><buffer> ]] m':call search('^\s*\(fu\%[nction]\\|\(export\s\+\)\?def\)\>', "W")<CR> | |
80 vnoremap <silent><buffer> ]] m':<C-U>exe "normal! gv"<Bar>call search('^\s*\(fu\%[nction]\\|\(export\s\+\)\?def\)\>', "W")<CR> | |
81 nnoremap <silent><buffer> [] m':call search('^\s*end\(f\%[unction]\\|\(export\s\+\)\?def\)\>', "bW")<CR> | |
82 vnoremap <silent><buffer> [] m':<C-U>exe "normal! gv"<Bar>call search('^\s*end\(f\%[unction]\\|\(export\s\+\)\?def\)\>', "bW")<CR> | |
83 nnoremap <silent><buffer> ][ m':call search('^\s*end\(f\%[unction]\\|\(export\s\+\)\?def\)\>', "W")<CR> | |
84 vnoremap <silent><buffer> ][ m':<C-U>exe "normal! gv"<Bar>call search('^\s*end\(f\%[unction]\\|\(export\s\+\)\?def\)\>', "W")<CR> | |
7 | 85 |
13051 | 86 " Move around comments |
87 nnoremap <silent><buffer> ]" :call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR> | |
88 vnoremap <silent><buffer> ]" :<C-U>exe "normal! gv"<Bar>call search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR> | |
89 nnoremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR> | |
90 vnoremap <silent><buffer> [" :<C-U>exe "normal! gv"<Bar>call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR> | |
91 endif | |
7 | 92 |
93 " Let the matchit plugin know what items can be matched. | |
94 if exists("loaded_matchit") | |
95 let b:match_ignorecase = 0 | |
23737 | 96 " "func" can also be used as a type: |
97 " var Ref: func | |
98 " or to list functions: | |
99 " func name | |
100 " require a parenthesis following, then there can be an "endfunc". | |
7 | 101 let b:match_words = |
32004 | 102 \ '\<\%(fu\%[nction]\|def\)!\=\s\+\S\+\s*(:\%(\%(^\||\)\s*\)\@<=\<retu\%[rn]\>:\%(\%(^\||\)\s*\)\@<=\<\%(endf\%[unction]\|enddef\)\>,' .. |
103 \ '\<\%(wh\%[ile]\|for\)\>:\%(\%(^\||\)\s*\)\@<=\<brea\%[k]\>:\%(\%(^\||\)\s*\)\@<=\<con\%[tinue]\>:\%(\%(^\||\)\s*\)\@<=\<end\%(w\%[hile]\|fo\%[r]\)\>,' .. | |
104 \ '\<if\>:\%(\%(^\||\)\s*\)\@<=\<el\%[seif]\>:\%(\%(^\||\)\s*\)\@<=\<en\%[dif]\>,' .. | |
105 \ '{:},' .. | |
106 \ '\<try\>:\%(\%(^\||\)\s*\)\@<=\<cat\%[ch]\>:\%(\%(^\||\)\s*\)\@<=\<fina\%[lly]\>:\%(\%(^\||\)\s*\)\@<=\<endt\%[ry]\>,' .. | |
107 \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,' .. | |
108 \ '\<class\>:\<endclass\>,' .. | |
109 \ '\<inte\%[rface]\>:\<endinterface\>,' .. | |
110 \ '\<enu\%[m]\>:\<endenum\>,' | |
111 | |
6213 | 112 " Ignore syntax region commands and settings, any 'en*' would clobber |
113 " if-endif. | |
114 " - set spl=de,en | |
115 " - au! FileType javascript syntax region foldBraces start=/{/ end=/}/ … | |
32004 | 116 " Also ignore here-doc and dictionary keys (vimVar). |
117 let b:match_skip = 'synIDattr(synID(line("."), col("."), 1), "name") | |
118 \ =~? "comment\\|string\\|vimSynReg\\|vimSet\\|vimLetHereDoc\\|vimVar"' | |
7 | 119 endif |
120 | |
2034 | 121 let &cpo = s:cpo_save |
122 unlet s:cpo_save | |
168 | 123 |
124 " removed this, because 'cpoptions' is a global option. | |
125 " setlocal cpo+=M " makes \%( match \) |