~gpanders/dotfiles

ref: 2da1dde5ea566f82ebe6532bc6d3b8670fd77ce8 dotfiles/vim/.vim/after/ftplugin/python.vim -rw-r--r-- 1.1 KiB
2da1dde5Greg Anders Note 'open' subcommand opens editor in NOTES_DIR when no argument given 1 year, 4 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
" Python specific settings
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*=

" 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 !empty(&l:formatprg)
  let b:undo_ftplugin .= '|setl fp<'
endif