diff --git a/ftplugin/javascript.vim b/ftplugin/javascript.vim index d84f662..5347c11 100644 --- a/ftplugin/javascript.vim +++ b/ftplugin/javascript.vim @@ -14,7 +14,7 @@ let s:prgpath = s:bundleDir."/js-beautify/python/".s:prgname if executable(s:prgpath) "If js-beautify is installed as a bundle - let &formatprg=s:prgpath." ".s:arguments + let b:formatprg=s:prgpath." ".s:arguments else "Else look for js-beautify globally "or in the formatters/folder diff --git a/ftplugin/python.vim b/ftplugin/python.vim index a925bd8..4702f3b 100644 --- a/ftplugin/python.vim +++ b/ftplugin/python.vim @@ -14,4 +14,5 @@ call g:FindFormatter(s:prgname, s:arguments) "Set indenting behaviour to match with the formatter set expandtab set tabstop=4 +set softtabstop=4 set shiftwidth=4 diff --git a/plugin/autoformat.vim b/plugin/autoformat.vim index 2a26eb1..b011239 100644 --- a/plugin/autoformat.vim +++ b/plugin/autoformat.vim @@ -29,11 +29,13 @@ function! g:FindFormatter(name, args) endif if executable(s:prgpath) - let &formatprg=s:prgpath." ".a:args - let w:formatprg=&formatprg - let t:formatprg=&formatprg - let b:formatprg=&formatprg + let b:formatprg=s:prgpath." ".a:args endif endfunction -"TODO: Now when buffer/window/tab changes, reload formatprg from the vars +"formatprg is a global option +"So when buffer/window/tab changes, (re)load formatprg from the bufferlocal +"variable +au BufEnter,WinEnter * let &formatprg=b:formatprg +"Default value for b:formatprg is empty string +let b:formatprg = ""