blob: 59afdb55671b0e73000ba0e98fb143e17679c613 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: python
3" Maintainer: Johannes Zellner <johannes@zellner.org>
Bram Moolenaar36782082013-11-28 13:53:34 +01004" Last Change: 2013 Nov 28
Bram Moolenaarb1332082013-10-06 14:22:40 +02005" Last Change By Johannes: Wed, 21 Apr 2004 13:13:08 CEST
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7if exists("b:did_ftplugin") | finish | endif
8let b:did_ftplugin = 1
Bram Moolenaar9a7224b2012-04-30 15:56:52 +02009let s:keepcpo= &cpo
10set cpo&vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000011
12setlocal cinkeys-=0#
13setlocal indentkeys-=0#
14setlocal include=\s*\\(from\\\|import\\)
15setlocal includeexpr=substitute(v:fname,'\\.','/','g')
16setlocal suffixesadd=.py
Bram Moolenaar36782082013-11-28 13:53:34 +010017setlocal comments=b:#,fb:-
18setlocal commentstring=#\ %s
Bram Moolenaar071d4272004-06-13 20:20:40 +000019
Bram Moolenaar18144c82006-04-12 21:52:12 +000020setlocal omnifunc=pythoncomplete#Complete
Bram Moolenaara40ceaf2006-01-13 22:35:40 +000021
Bram Moolenaar071d4272004-06-13 20:20:40 +000022set wildignore+=*.pyc
23
24nnoremap <silent> <buffer> ]] :call <SID>Python_jump('/^\(class\\|def\)')<cr>
25nnoremap <silent> <buffer> [[ :call <SID>Python_jump('?^\(class\\|def\)')<cr>
26nnoremap <silent> <buffer> ]m :call <SID>Python_jump('/^\s*\(class\\|def\)')<cr>
27nnoremap <silent> <buffer> [m :call <SID>Python_jump('?^\s*\(class\\|def\)')<cr>
28
Bram Moolenaar36782082013-11-28 13:53:34 +010029if !exists('*<SID>Python_jump')
30 fun! <SID>Python_jump(motion) range
31 let cnt = v:count1
32 let save = @/ " save last search pattern
33 mark '
34 while cnt > 0
35 silent! exe a:motion
36 let cnt = cnt - 1
37 endwhile
38 call histdel('/', -1)
39 let @/ = save " restore last search pattern
40 endfun
41endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000042
Bram Moolenaar36782082013-11-28 13:53:34 +010043if has("browsefilter") && !exists("b:browsefilter")
Bram Moolenaar071d4272004-06-13 20:20:40 +000044 let b:browsefilter = "Python Files (*.py)\t*.py\n" .
45 \ "All Files (*.*)\t*.*\n"
46endif
Bram Moolenaar9a7224b2012-04-30 15:56:52 +020047
Bram Moolenaarb1332082013-10-06 14:22:40 +020048" As suggested by PEP8.
49setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
50
51" First time: try finding "pydoc".
52if !exists('g:pydoc_executable')
53 if executable('pydoc')
54 let g:pydoc_executable = 1
55 else
56 let g:pydoc_executable = 0
57 endif
58endif
59" If "pydoc" was found use it for keywordprg.
60if g:pydoc_executable
61 setlocal keywordprg=pydoc
62endif
63
Bram Moolenaar9a7224b2012-04-30 15:56:52 +020064let &cpo = s:keepcpo
65unlet s:keepcpo