blob: 9e2c5a763e12bf88464a5127567ed810dc7c2730 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: python
Bram Moolenaarc95a3022016-06-12 23:01:46 +02003" Maintainer: James Sully <sullyj3@gmail.com>
4" Previous Maintainer: Johannes Zellner <johannes@zellner.org>
5" Last Change: Fri, 10 June 2016
6" https://github.com/sullyj3/vim-ftplugin-python
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
8if exists("b:did_ftplugin") | finish | endif
9let b:did_ftplugin = 1
Bram Moolenaar9a7224b2012-04-30 15:56:52 +020010let s:keepcpo= &cpo
11set cpo&vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000012
13setlocal cinkeys-=0#
14setlocal indentkeys-=0#
Bram Moolenaar92dff182014-02-11 19:15:50 +010015setlocal include=^\\s*\\(from\\\|import\\)
Bram Moolenaar071d4272004-06-13 20:20:40 +000016setlocal includeexpr=substitute(v:fname,'\\.','/','g')
17setlocal suffixesadd=.py
Bram Moolenaar36782082013-11-28 13:53:34 +010018setlocal comments=b:#,fb:-
19setlocal commentstring=#\ %s
Bram Moolenaar071d4272004-06-13 20:20:40 +000020
Bram Moolenaar18144c82006-04-12 21:52:12 +000021setlocal omnifunc=pythoncomplete#Complete
Bram Moolenaara40ceaf2006-01-13 22:35:40 +000022
Bram Moolenaar071d4272004-06-13 20:20:40 +000023set wildignore+=*.pyc
24
Bram Moolenaarc95a3022016-06-12 23:01:46 +020025nnoremap <silent> <buffer> ]] :call <SID>Python_jump('/^\(class\\|def\)\>')<cr>
26nnoremap <silent> <buffer> [[ :call <SID>Python_jump('?^\(class\\|def\)\>')<cr>
27nnoremap <silent> <buffer> ]m :call <SID>Python_jump('/^\s*\(class\\|def\)\>')<cr>
28nnoremap <silent> <buffer> [m :call <SID>Python_jump('?^\s*\(class\\|def\)\>')<cr>
Bram Moolenaar071d4272004-06-13 20:20:40 +000029
Bram Moolenaar36782082013-11-28 13:53:34 +010030if !exists('*<SID>Python_jump')
31 fun! <SID>Python_jump(motion) range
32 let cnt = v:count1
33 let save = @/ " save last search pattern
34 mark '
35 while cnt > 0
36 silent! exe a:motion
37 let cnt = cnt - 1
38 endwhile
39 call histdel('/', -1)
40 let @/ = save " restore last search pattern
41 endfun
42endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000043
Bram Moolenaar36782082013-11-28 13:53:34 +010044if has("browsefilter") && !exists("b:browsefilter")
Bram Moolenaar071d4272004-06-13 20:20:40 +000045 let b:browsefilter = "Python Files (*.py)\t*.py\n" .
46 \ "All Files (*.*)\t*.*\n"
47endif
Bram Moolenaar9a7224b2012-04-30 15:56:52 +020048
Bram Moolenaarb1332082013-10-06 14:22:40 +020049" As suggested by PEP8.
50setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
51
52" First time: try finding "pydoc".
53if !exists('g:pydoc_executable')
54 if executable('pydoc')
55 let g:pydoc_executable = 1
56 else
57 let g:pydoc_executable = 0
58 endif
59endif
60" If "pydoc" was found use it for keywordprg.
61if g:pydoc_executable
62 setlocal keywordprg=pydoc
63endif
64
Bram Moolenaar9a7224b2012-04-30 15:56:52 +020065let &cpo = s:keepcpo
66unlet s:keepcpo