Mercurial > vim
annotate runtime/ftplugin/python.vim @ 11945:f37815bb7417 v8.0.0852
patch 8.0.0852: MS-Windows: possible crash when giving a message on startup
commit https://github.com/vim/vim/commit/1b66c00aeca87913e75012c59c4e969316e2626d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 3 18:55:00 2017 +0200
patch 8.0.0852: MS-Windows: possible crash when giving a message on startup
Problem: MS-Windows: possible crash when giving a message on startup.
Solution: Initialize length. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/1931)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 03 Aug 2017 19:00:05 +0200 |
parents | bdd7fc1a38c0 |
children | 3b26420fc639 |
rev | line source |
---|---|
7 | 1 " Vim filetype plugin file |
2 " Language: python | |
9286
64035abb986b
commit https://github.com/vim/vim/commit/c95a302a4c42ec8230473cd4a5e0064d0a143aa8
Christian Brabandt <cb@256bit.org>
parents:
5663
diff
changeset
|
3 " Maintainer: James Sully <sullyj3@gmail.com> |
64035abb986b
commit https://github.com/vim/vim/commit/c95a302a4c42ec8230473cd4a5e0064d0a143aa8
Christian Brabandt <cb@256bit.org>
parents:
5663
diff
changeset
|
4 " Previous Maintainer: Johannes Zellner <johannes@zellner.org> |
10261
bdd7fc1a38c0
commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents:
10153
diff
changeset
|
5 " Last Change: Tue, 09 October 2016 |
9286
64035abb986b
commit https://github.com/vim/vim/commit/c95a302a4c42ec8230473cd4a5e0064d0a143aa8
Christian Brabandt <cb@256bit.org>
parents:
5663
diff
changeset
|
6 " https://github.com/sullyj3/vim-ftplugin-python |
7 | 7 |
8 if exists("b:did_ftplugin") | finish | endif | |
9 let b:did_ftplugin = 1 | |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
827
diff
changeset
|
10 let s:keepcpo= &cpo |
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
827
diff
changeset
|
11 set cpo&vim |
7 | 12 |
13 setlocal cinkeys-=0# | |
14 setlocal indentkeys-=0# | |
5663
1dea14d4c738
Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
5510
diff
changeset
|
15 setlocal include=^\\s*\\(from\\\|import\\) |
7 | 16 setlocal includeexpr=substitute(v:fname,'\\.','/','g') |
17 setlocal suffixesadd=.py | |
5510 | 18 setlocal comments=b:#,fb:- |
19 setlocal commentstring=#\ %s | |
7 | 20 |
827 | 21 setlocal omnifunc=pythoncomplete#Complete |
626 | 22 |
7 | 23 set wildignore+=*.pyc |
24 | |
10261
bdd7fc1a38c0
commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents:
10153
diff
changeset
|
25 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
|
26 let b:prev_toplevel='\v^(class\|def\|async def)>' |
bdd7fc1a38c0
commit https://github.com/vim/vim/commit/dc08328821a2c11e33dfb1980332e4923ec64fca
Christian Brabandt <cb@256bit.org>
parents:
10153
diff
changeset
|
27 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
|
28 let b:prev='\v^\s*(class\|def\|async def)>' |
10153
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
29 |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
30 execute "nnoremap <silent> <buffer> ]] :call <SID>Python_jump('n', '". b:next_toplevel."', 'W')<cr>" |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
31 execute "nnoremap <silent> <buffer> [[ :call <SID>Python_jump('n', '". b:prev_toplevel."', 'Wb')<cr>" |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
32 execute "nnoremap <silent> <buffer> ]m :call <SID>Python_jump('n', '". b:next."', 'W')<cr>" |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
33 execute "nnoremap <silent> <buffer> [m :call <SID>Python_jump('n', '". b:prev."', 'Wb')<cr>" |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
34 |
10153
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
35 execute "onoremap <silent> <buffer> ]] :call <SID>Python_jump('o', '". b:next_toplevel."', 'W')<cr>" |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
36 execute "onoremap <silent> <buffer> [[ :call <SID>Python_jump('o', '". b:prev_toplevel."', 'Wb')<cr>" |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
37 execute "onoremap <silent> <buffer> ]m :call <SID>Python_jump('o', '". b:next."', 'W')<cr>" |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
38 execute "onoremap <silent> <buffer> [m :call <SID>Python_jump('o', '". b:prev."', 'Wb')<cr>" |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
39 |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
40 execute "xnoremap <silent> <buffer> ]] :call <SID>Python_jump('x', '". b:next_toplevel."', 'W')<cr>" |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
41 execute "xnoremap <silent> <buffer> [[ :call <SID>Python_jump('x', '". b:prev_toplevel."', 'Wb')<cr>" |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
42 execute "xnoremap <silent> <buffer> ]m :call <SID>Python_jump('x', '". b:next."', 'W')<cr>" |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
43 execute "xnoremap <silent> <buffer> [m :call <SID>Python_jump('x', '". b:prev."', 'Wb')<cr>" |
7 | 44 |
5510 | 45 if !exists('*<SID>Python_jump') |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
46 fun! <SID>Python_jump(mode, motion, flags) range |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
47 if a:mode == 'x' |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
48 normal! gv |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
49 endif |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
50 |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
51 normal! 0 |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
52 |
5510 | 53 let cnt = v:count1 |
54 mark ' | |
55 while cnt > 0 | |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
56 call search(a:motion, a:flags) |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
57 let cnt = cnt - 1 |
5510 | 58 endwhile |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
59 |
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
9286
diff
changeset
|
60 normal! ^ |
5510 | 61 endfun |
62 endif | |
7 | 63 |
5510 | 64 if has("browsefilter") && !exists("b:browsefilter") |
7 | 65 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
|
66 \ "All Files (*.*)\t*.*\n" |
7 | 67 endif |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
827
diff
changeset
|
68 |
10153
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
69 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
|
70 " As suggested by PEP8. |
715d6c5707b8
commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents:
10140
diff
changeset
|
71 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
|
72 endif |
5400 | 73 |
74 " First time: try finding "pydoc". | |
75 if !exists('g:pydoc_executable') | |
76 if executable('pydoc') | |
77 let g:pydoc_executable = 1 | |
78 else | |
79 let g:pydoc_executable = 0 | |
80 endif | |
81 endif | |
82 " If "pydoc" was found use it for keywordprg. | |
83 if g:pydoc_executable | |
84 setlocal keywordprg=pydoc | |
85 endif | |
86 | |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
827
diff
changeset
|
87 let &cpo = s:keepcpo |
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
827
diff
changeset
|
88 unlet s:keepcpo |