/usr/share/vim/addons/ftplugin/python_autopep8.vim is in vim-autopep8 1.0.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | "=========================================================
" File: python_autopep8.vim
" Author: tell-k <ffk2005[at]gmail.com>
" Last Change: 23-May-2014.
" Version: 1.0.6
" WebPage: https://github.com/tell-k/vim-autopep8
" License: MIT Licence
"==========================================================
" see also README.rst
" Only do this when not done yet for this buffer
if exists("b:loaded_autopep8_ftplugin")
finish
endif
let b:loaded_autopep8_ftplugin=1
if !exists("*Autopep8(...)")
function Autopep8(...)
let l:args = get(a:, 1, '')
if exists("g:autopep8_cmd")
let autopep8_cmd=g:autopep8_cmd
else
let autopep8_cmd="autopep8"
endif
if !executable(autopep8_cmd)
echoerr "File " . autopep8_cmd . " not found. Please install it first."
return
endif
if exists("g:autopep8_ignore")
let autopep8_ignores=" --ignore=".g:autopep8_ignore
else
let autopep8_ignores=""
endif
if exists("g:autopep8_select")
let autopep8_selects=" --select=".g:autopep8_select
else
let autopep8_selects=""
endif
if exists("g:autopep8_pep8_passes")
let autopep8_pep8_passes=" --pep8-passes=".g:autopep8_pep8_passes
else
let autopep8_pep8_passes=""
endif
if exists("g:autopep8_max_line_length")
let autopep8_max_line_length=" --max-line-length=".g:autopep8_max_line_length
else
let autopep8_max_line_length=""
endif
if exists("g:autopep8_aggressive")
let autopep8_aggressive=" --aggressive "
else
let autopep8_aggressive=""
endif
if exists("g:autopep8_indent_size")
let autopep8_indent_size=" --indent-size=".g:autopep8_indent_size
else
let autopep8_indent_size=""
endif
let execmdline=autopep8_cmd.autopep8_pep8_passes.autopep8_selects.autopep8_ignores.autopep8_max_line_length.autopep8_aggressive.autopep8_indent_size.l:args
let tmpfile = tempname()
let tmpdiff = tempname()
let index = 0
try
" current cursor
let current_cursor = getpos(".")
" write to temporary file
silent execute "!". execmdline . " \"" . expand('%:p') . "\" > " . tmpfile
if !exists("g:autopep8_disable_show_diff")
silent execute "!". execmdline . " --diff \"" . expand('%:p') . "\" > " . tmpdiff
endif
" current buffer all delete
silent execute "%d"
" read temp file. and write to current buffer.
for line in readfile(tmpfile)
call append(index, line)
let index = index + 1
endfor
" remove last linebreak.
silent execute ":" . index . "," . index . "s/\\n$//g"
" restore cursor
call setpos('.', current_cursor)
" show diff
if !exists("g:autopep8_disable_show_diff")
botright new autopep8
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
silent execute '$read ' . tmpdiff
setlocal nomodifiable
setlocal nu
setlocal filetype=diff
else
redraw!
endif
hi Green ctermfg=green
echohl Green
echon "Fixed with autopep8 this file."
echohl
finally
" file close
if filewritable(tmpfile)
call delete(tmpfile)
endif
if filewritable(tmpdiff)
call delete(tmpdiff)
endif
endtry
endfunction
endif
" Add mappings, unless the user didn't want this.
" The default mapping is registered under to <F8> by default, unless the user
" remapped it already (or a mapping exists already for <F8>)
if !exists("no_plugin_maps") && !exists("no_autopep8_maps")
if !hasmapto('Autopep8(')
noremap <buffer> <F8> :call Autopep8()<CR>
command! -nargs=? -bar Autopep8 call Autopep8(<f-args>)
endif
endif
|