extending vim with shell commands | 11

using BufWritePost for formatters

My old config written in vimscript if you care.

function! s:PyPreSave()
    Black
endfunction

function! s:PyPostSave()
    execute "!tidy-imports --black --quiet --replace-star-imports --action REPLACE " . bufname("%")
    execute "!isort " . bufname("%")
    execute "!black " . bufname("%")
    execute "e"
endfunction

:command! PyPreSave :call s:PyPreSave()
:command! PyPostSave :call s:PyPostSave()

augroup waylonwalker
    autocmd!
    autocmd bufwritepre *.py silent! execute 'PyPreSave'
    autocmd bufwritepost *.py silent! execute 'PyPostSave'
augroup end