Created
November 9, 2021 14:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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