1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
set shiftwidth=4 tabstop=4 softtabstop=4 expandtab autoindent smartindent
setlocal path=.,**
setlocal wildignore=*/__pycache__/*,*.pyc
set include=^\\s*\\(from\\\|import\\)\\s*\\zs\\(\\S\\+\\s\\{-}\\)*\\ze\\($\\\|\ as\\)
function! PyInclude(fname)
let parts = split(a:fname, ' import ')
let l = parts[0]
if len(parts) > 1
let r = parts[1]
let joined = join([l, r], '.')
let fp = substitute(joined, '\.', '/', 'g') . '.py'
let found = glob(fp, 1)
if len(found)
return substitute(joined, '\.', '/', 'g') . '.py'
endif
endif
return substitute(joined, '\.', '/', 'g') . '.py'
endfunction
setlocal includeexpr=PyInclude(v:fname)
setlocal define=^\\s*\\<\\(def\\\|class\\)\\>
nnoremap <leader>pp :!pycodestyle --first %<CR>
|