Commit c968edcb authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add vim-autoformat plugin

parent a426a6da
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -79,3 +79,6 @@
[submodule ".vim/bundle/vim-go"]
	path = .vim/bundle/vim-go
	url = https://github.com/fatih/vim-go.git
[submodule ".vim/bundle/vim-autoformat"]
	path = .vim/bundle/vim-autoformat
	url = https://github.com/Chiel92/vim-autoformat.git
Original line number Diff line number Diff line
Subproject commit a350538f8a5a8f08cf64a520d456282080c3968f
+27 −0
Original line number Diff line number Diff line
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0

function s:formatdef_electric()
	if &l:expandtab == 0
		let cmd = "electric"
	else
		let cmd = "black"
	endif
	let cmd .= " - --quiet --line-length=".&l:textwidth
	return '"'.cmd.'"'
endfunction

let g:formatters_python = ['electric']

augroup autoformat
au BufNewFile,BufRead *.py
			\ :let b:formatdef_electric = <SID>formatdef_electric()
au BufNewFile,BufRead *.py
			\ :au OptionSet expandtab
			\ :let b:formatdef_electric = <SID>formatdef_electric()
au BufNewFile,BufRead *.py
			\ :au OptionSet textwidth
			\ :let b:formatdef_electric = <SID>formatdef_electric()
au BufWritePre *.py :Autoformat
augroup END