~gpanders/dotfiles

ref: 1e9f8dd001f12b57c7ff1b45adb7c59541b752c6 dotfiles/.vim/after/ftplugin/python.vim -rw-r--r-- 1.3 KiB
1e9f8dd0Gregory Anders fish: remove fuzzy finder from buku alias 6 months ago
                                                                                
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')

" Set textwidth to 88 to mimic black
setlocal textwidth=88

" Set format options
setlocal formatoptions-=t " Don't auto-wrap lines unless they're comments

" Use indent for foldmethod
setlocal foldmethod=indent
setlocal foldnestmax=2

let b:undo_ftplugin .= '|setl tw< fo< fdm< fdn<'

" Make [d, [i, etc. find variables defined at the top-level (no indent)
setlocal define=^\\ze\\i\\+\\s*=

if exists('$VIRTUAL_ENV') && filereadable($VIRTUAL_ENV . '/tags')
    let &l:tags = $VIRTUAL_ENV . '/tags,' . &tags
endif

" Try to infer python version from shebang
let s:python = matchstr(getline(1), '^#!.*\zspython\([23]\)\?')

" Populate path from python's sys.path
call ft#python#set_path(s:python)
let b:undo_ftplugin .= '|setl path<'

" Use a wrapper around the default !pydoc command for keywordprg
command! -buffer -nargs=? Pydoc call ft#python#pydoc(<q-args>)
setlocal keywordprg=:Pydoc
let b:undo_ftplugin .= '|delc Pydoc|setl kp<'

if executable('black')
    setlocal formatprg=black\ -q\ -\ 2>/dev/null
elseif executable('yapf')
    setlocal formatprg=yapf
endif

if executable('isort')
    if empty(&l:formatprg)
        setlocal formatprg=isort\ -q\ -
    else
        setlocal formatprg+=\ \|\ isort\ -q\ -
    endif
endif

if !empty(&l:formatprg)
    let b:undo_ftplugin .= '|setl fp<'
endif