Mercurial > vim
annotate runtime/ftplugin/python.vim @ 21783:483dc3fd596c v8.2.1441
patch 8.2.1441: running tests in tiny version gives error for summarize.vim
Commit: https://github.com/vim/vim/commit/c771908681bc9ee7689d83e09104cf4c6f984326
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 13 19:42:39 2020 +0200
patch 8.2.1441: running tests in tiny version gives error for summarize.vim
Problem: Running tests in tiny version gives error for summarize.vim.
Solution: Set 'cpoptions' to allow for line continuation. Restore
redirecting test output to /dev/null.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 13 Aug 2020 19:45:04 +0200 |
parents | bd7461db24b3 |
children | 17c4178f26ea |
rev | line source |
---|---|
7 | 1 " Vim filetype plugin file |
2 " Language: python | |
12756
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
3 " Maintainer: Tom Picton <tom@tompicton.co.uk> |
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
4 " Previous Maintainer: James Sully <sullyj3@gmail.com> |
9286
64035abb986b
commit https://github.com/vim/vim/commit/c95a302a4c42ec8230473cd4a5e0064d0a143aa8
Christian Brabandt <cb@256bit.org>
parents:
5663
diff
changeset
|
5 " Previous Maintainer: Johannes Zellner <johannes@zellner.org> |
16086 | 6 " Last Change: Sun 17 Mar 2019 |
12756
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
7 " https://github.com/tpict/vim-ftplugin-python |
7 | 8 |
9 if exists("b:did_ftplugin") | finish | endif | |
10 let b:did_ftplugin = 1 | |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
827
diff
changeset
|
11 let s:keepcpo= &cpo |
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
827
diff
changeset
|
12 set cpo&vim |
7 | 13 |
14 setlocal cinkeys-=0# | |
15 setlocal indentkeys-=0# | |
5663
1dea14d4c738
Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
5510
diff
changeset
|
16 setlocal include=^\\s*\\(from\\\|import\\) |
13482
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
17 |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
18 " For imports with leading .., append / and replace additional .s with ../ |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
19 let b:grandparent_match = '^\(.\.\)\(\.*\)' |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
20 let b:grandparent_sub = '\=submatch(1)."/".repeat("../",strlen(submatch(2)))' |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
21 |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
22 " For imports with a single leading ., replace it with ./ |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
23 let b:parent_match = '^\.\(\.\)\@!' |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
24 let b:parent_sub = './' |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
25 |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
26 " Replace any . sandwiched between word characters with / |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
27 let b:child_match = '\(\w\)\.\(\w\)' |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
28 let b:child_sub = '\1/\2' |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
29 |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
30 setlocal includeexpr=substitute(substitute(substitute( |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
31 \v:fname, |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
32 \b:grandparent_match,b:grandparent_sub,''), |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
33 \b:parent_match,b:parent_sub,''), |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
34 \b:child_match,b:child_sub,'g') |
9eebe457eb3c
Update runtime files. Convert a couple of help files to utf-8.
Christian Brabandt <cb@256bit.org>
parents:
13125
diff
changeset
|
35 |
7 | 36 setlocal suffixesadd=.py |
5510 | 37 setlocal comments=b:#,fb:- |
38 setlocal commentstring=#\ %s | |
7 | 39 |
13125 | 40 if has('python3') |
16086 | 41 setlocal omnifunc=python3complete#Complete |
42 elseif has('python') | |
43 setlocal omnifunc=pythoncomplete#Complete | |
13125 | 44 endif |
626 | 45 |
7 | 46 set wildignore+=*.pyc |
47 | |
10261
bdd7fc1a38c0
commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents:
10153
diff
changeset
|
48 let b:next_toplevel='\v%$\|^(class\|def\|async def)>' |
bdd7fc1a38c0
commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents:
10153
diff
changeset
|
49 let b:prev_toplevel='\v^(class\|def\|async def)>' |
12756
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
50 let b:next_endtoplevel='\v%$\|\S.*\n+(def\|class)' |
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
51 let b:prev_endtoplevel='\v\S.*\n+(def\|class)' |
10261
bdd7fc1a38c0
commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents:
10153
diff
changeset
|
52 let b:next='\v%$\|^\s*(class\|def\|async def)>' |
bdd7fc1a38c0
commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents:
10153
diff
changeset
|
53 let b:prev='\v^\s*(class\|def\|async def)>' |
12826 | 54 let b:next_end='\v\S\n*(%$\|^(\s*\n*)*(class\|def\|async def)\|^\S)' |
55 let b:prev_end='\v\S\n*(^(\s*\n*)*(class\|def\|async def)\|^\S)' | |
10153
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
56 |
16086 | 57 if !exists('g:no_plugin_maps') && !exists('g:no_python_maps') |
58 execute "nnoremap <silent> <buffer> ]] :call <SID>Python_jump('n', '". b:next_toplevel."', 'W', v:count1)<cr>" | |
59 execute "nnoremap <silent> <buffer> [[ :call <SID>Python_jump('n', '". b:prev_toplevel."', 'Wb', v:count1)<cr>" | |
60 execute "nnoremap <silent> <buffer> ][ :call <SID>Python_jump('n', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>" | |
61 execute "nnoremap <silent> <buffer> [] :call <SID>Python_jump('n', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>" | |
62 execute "nnoremap <silent> <buffer> ]m :call <SID>Python_jump('n', '". b:next."', 'W', v:count1)<cr>" | |
63 execute "nnoremap <silent> <buffer> [m :call <SID>Python_jump('n', '". b:prev."', 'Wb', v:count1)<cr>" | |
64 execute "nnoremap <silent> <buffer> ]M :call <SID>Python_jump('n', '". b:next_end."', 'W', v:count1, 0)<cr>" | |
65 execute "nnoremap <silent> <buffer> [M :call <SID>Python_jump('n', '". b:prev_end."', 'Wb', v:count1, 0)<cr>" | |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
66 |
16086 | 67 execute "onoremap <silent> <buffer> ]] :call <SID>Python_jump('o', '". b:next_toplevel."', 'W', v:count1)<cr>" |
68 execute "onoremap <silent> <buffer> [[ :call <SID>Python_jump('o', '". b:prev_toplevel."', 'Wb', v:count1)<cr>" | |
69 execute "onoremap <silent> <buffer> ][ :call <SID>Python_jump('o', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>" | |
70 execute "onoremap <silent> <buffer> [] :call <SID>Python_jump('o', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>" | |
71 execute "onoremap <silent> <buffer> ]m :call <SID>Python_jump('o', '". b:next."', 'W', v:count1)<cr>" | |
72 execute "onoremap <silent> <buffer> [m :call <SID>Python_jump('o', '". b:prev."', 'Wb', v:count1)<cr>" | |
73 execute "onoremap <silent> <buffer> ]M :call <SID>Python_jump('o', '". b:next_end."', 'W', v:count1, 0)<cr>" | |
74 execute "onoremap <silent> <buffer> [M :call <SID>Python_jump('o', '". b:prev_end."', 'Wb', v:count1, 0)<cr>" | |
10153
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
75 |
16086 | 76 execute "xnoremap <silent> <buffer> ]] :call <SID>Python_jump('x', '". b:next_toplevel."', 'W', v:count1)<cr>" |
77 execute "xnoremap <silent> <buffer> [[ :call <SID>Python_jump('x', '". b:prev_toplevel."', 'Wb', v:count1)<cr>" | |
78 execute "xnoremap <silent> <buffer> ][ :call <SID>Python_jump('x', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>" | |
79 execute "xnoremap <silent> <buffer> [] :call <SID>Python_jump('x', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>" | |
80 execute "xnoremap <silent> <buffer> ]m :call <SID>Python_jump('x', '". b:next."', 'W', v:count1)<cr>" | |
81 execute "xnoremap <silent> <buffer> [m :call <SID>Python_jump('x', '". b:prev."', 'Wb', v:count1)<cr>" | |
82 execute "xnoremap <silent> <buffer> ]M :call <SID>Python_jump('x', '". b:next_end."', 'W', v:count1, 0)<cr>" | |
83 execute "xnoremap <silent> <buffer> [M :call <SID>Python_jump('x', '". b:prev_end."', 'Wb', v:count1, 0)<cr>" | |
84 endif | |
7 | 85 |
5510 | 86 if !exists('*<SID>Python_jump') |
13735 | 87 fun! <SID>Python_jump(mode, motion, flags, count, ...) range |
12756
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
88 let l:startofline = (a:0 >= 1) ? a:1 : 1 |
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
89 |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
90 if a:mode == 'x' |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
91 normal! gv |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
92 endif |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
93 |
12756
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
94 if l:startofline == 1 |
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
95 normal! 0 |
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
96 endif |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
97 |
13735 | 98 let cnt = a:count |
5510 | 99 mark ' |
100 while cnt > 0 | |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
101 call search(a:motion, a:flags) |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
102 let cnt = cnt - 1 |
5510 | 103 endwhile |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
104 |
12756
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
105 if l:startofline == 1 |
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
106 normal! ^ |
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
10261
diff
changeset
|
107 endif |
5510 | 108 endfun |
109 endif | |
7 | 110 |
5510 | 111 if has("browsefilter") && !exists("b:browsefilter") |
7 | 112 let b:browsefilter = "Python Files (*.py)\t*.py\n" . |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
113 \ "All Files (*.*)\t*.*\n" |
7 | 114 endif |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
827
diff
changeset
|
115 |
10153
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
116 if !exists("g:python_recommended_style") || g:python_recommended_style != 0 |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
117 " As suggested by PEP8. |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
118 setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8 |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
119 endif |
5400 | 120 |
121 " First time: try finding "pydoc". | |
122 if !exists('g:pydoc_executable') | |
123 if executable('pydoc') | |
124 let g:pydoc_executable = 1 | |
125 else | |
126 let g:pydoc_executable = 0 | |
127 endif | |
128 endif | |
16086 | 129 |
130 " Windows-specific pydoc setup | |
131 if has('win32') || has('win64') | |
132 if executable('python') | |
133 " available as Tools\scripts\pydoc.py | |
134 let g:pydoc_executable = 1 | |
135 else | |
136 let g:pydoc_executable = 0 | |
137 endif | |
138 endif | |
139 | |
5400 | 140 " If "pydoc" was found use it for keywordprg. |
141 if g:pydoc_executable | |
16086 | 142 if has('win32') || has('win64') |
143 setlocal keywordprg=python\ -m\ pydoc\ | |
144 else | |
145 setlocal keywordprg=pydoc | |
146 endif | |
5400 | 147 endif |
148 | |
16086 | 149 " Script for filetype switching to undo the local stuff we may have changed |
150 let b:undo_ftplugin = 'setlocal cinkeys<' | |
151 \ . '|setlocal comments<' | |
152 \ . '|setlocal commentstring<' | |
153 \ . '|setlocal expandtab<' | |
154 \ . '|setlocal include<' | |
155 \ . '|setlocal includeexpr<' | |
156 \ . '|setlocal indentkeys<' | |
157 \ . '|setlocal keywordprg<' | |
158 \ . '|setlocal omnifunc<' | |
159 \ . '|setlocal shiftwidth<' | |
160 \ . '|setlocal softtabstop<' | |
161 \ . '|setlocal suffixesadd<' | |
162 \ . '|setlocal tabstop<' | |
163 \ . '|silent! nunmap <buffer> [M' | |
164 \ . '|silent! nunmap <buffer> [[' | |
165 \ . '|silent! nunmap <buffer> []' | |
166 \ . '|silent! nunmap <buffer> [m' | |
167 \ . '|silent! nunmap <buffer> ]M' | |
168 \ . '|silent! nunmap <buffer> ][' | |
169 \ . '|silent! nunmap <buffer> ]]' | |
170 \ . '|silent! nunmap <buffer> ]m' | |
171 \ . '|silent! ounmap <buffer> [M' | |
172 \ . '|silent! ounmap <buffer> [[' | |
173 \ . '|silent! ounmap <buffer> []' | |
174 \ . '|silent! ounmap <buffer> [m' | |
175 \ . '|silent! ounmap <buffer> ]M' | |
176 \ . '|silent! ounmap <buffer> ][' | |
177 \ . '|silent! ounmap <buffer> ]]' | |
178 \ . '|silent! ounmap <buffer> ]m' | |
179 \ . '|silent! xunmap <buffer> [M' | |
180 \ . '|silent! xunmap <buffer> [[' | |
181 \ . '|silent! xunmap <buffer> []' | |
182 \ . '|silent! xunmap <buffer> [m' | |
183 \ . '|silent! xunmap <buffer> ]M' | |
184 \ . '|silent! xunmap <buffer> ][' | |
185 \ . '|silent! xunmap <buffer> ]]' | |
186 \ . '|silent! xunmap <buffer> ]m' | |
187 \ . '|unlet! b:browsefilter' | |
188 \ . '|unlet! b:child_match' | |
189 \ . '|unlet! b:child_sub' | |
190 \ . '|unlet! b:grandparent_match' | |
191 \ . '|unlet! b:grandparent_sub' | |
192 \ . '|unlet! b:next' | |
193 \ . '|unlet! b:next_end' | |
194 \ . '|unlet! b:next_endtoplevel' | |
195 \ . '|unlet! b:next_toplevel' | |
196 \ . '|unlet! b:parent_match' | |
197 \ . '|unlet! b:parent_sub' | |
198 \ . '|unlet! b:prev' | |
199 \ . '|unlet! b:prev_end' | |
200 \ . '|unlet! b:prev_endtoplevel' | |
201 \ . '|unlet! b:prev_toplevel' | |
202 \ . '|unlet! b:undo_ftplugin' | |
203 | |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
827
diff
changeset
|
204 let &cpo = s:keepcpo |
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
827
diff
changeset
|
205 unlet s:keepcpo |