python support and no error into buffer when formatter not installed

This commit is contained in:
Chiel92 2012-12-01 14:06:28 +01:00
parent 7eb56bbdb5
commit 19b7a6437b
4 changed files with 29 additions and 12 deletions

View File

@ -1,7 +1,10 @@
let s:CliOptions = "-d"
let s:bundleDir = fnamemodify(expand("<sfile>"), ":h:h:h")
let &formatprg=s:bundleDir."/js-beautify/python/js-beautify -i ".s:CliOptions
let s:prgpath = s:bundleDir."/js-beautify/python/js-beautify"
let s:arguments = "-i"
if executable(s:prgpath)
let &formatprg=s:prgpath." ".s:arguments
endif
set expandtab
set tabstop=4
set shiftwidth=4
set tabstop = 4
set shiftwidth = 4

View File

@ -1,2 +1,5 @@
let &formatprg="phpCB --space-after-if --space-after-switch --space-after-while --space-before-start-angle-bracket --space-after-end-angle-bracket --one-true-brace-function-declaration --glue-amperscore --change-shell-comment-to-double-slashes-comment --force-large-php-code-tag --force-true-false-null-contant-lowercase --align-equal-statements --comment-rendering-style PEAR --equal-align-position 50 --padding-char-count 4"
let s:prgpath-"phpCB"
let s:arguments="--space-after-if --space-after-switch --space-after-while --space-before-start-angle-bracket --space-after-end-angle-bracket --one-true-brace-function-declaration --glue-amperscore --change-shell-comment-to-double-slashes-comment --force-large-php-code-tag --force-true-false-null-contant-lowercase --align-equal-statements --comment-rendering-style PEAR --equal-align-position 50 --padding-char-count 4"
if executable(s:prgpath)
let &formatprg=s:prgpath." ".s:arguments
endif

5
ftplugin/python.vim Normal file
View File

@ -0,0 +1,5 @@
let s:prgpath = "autopep8"
let s:arguments = " /dev/stdin"
if executable(s:prgpath)
let &formatprg=s:prgpath." ".s:arguments
endif

View File

@ -1,9 +1,15 @@
"Function for formatting the entire buffer
function! g:Autoformat()
"Save window state
let winview=winsaveview()
"Autoformat code
:silent exe "normal gggqG"
"Recall window state
call winrestview(winview)
"If a formatprg is specified
if &formatprg!=""
"echo "formatprg is: ".&formatprg
"Save window state
let winview=winsaveview()
"Autoformat code
:silent exe "normal gggqG"
"Recall window state
call winrestview(winview)
else
echo "No formatter installed for this filetype"
endif
endfunction