Skip to content

Instantly share code, notes, and snippets.

@jettero
Created November 9, 2021 14:10
Show Gist options
  • Save jettero/6acd350ce6d40839f377a561b7e839c9 to your computer and use it in GitHub Desktop.
Save jettero/6acd350ce6d40839f377a561b7e839c9 to your computer and use it in GitHub Desktop.
A function to invoke psf-black in vim without any plugins or their frankenstalled virtual environment mini-pseudo-python-distro-hidden-directory-thing
fun Blackify()
let l:bsave = winsaveview()
let l:tname = tempname()
exe 'keepjumps %!black --line-length 119 -q - 2>' . l:tname
if v:shell_error > 0
let l:lines = readfile(l:tname)
for l:line in l:lines
echo l:line
endfor
call delete(l:tname)
endif
call winrestview(l:bsave)
endfun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment