fix: maintain view/folds when formatting on save (#31)

This commit is contained in:
Jeroen Op 't Eynde 2023-02-20 15:33:42 +01:00 committed by GitHub
parent 6ac3486c47
commit c2a3e8ca00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,9 +105,11 @@ function! jsonnet#Format()
call setfperm(expand('%'), l:originalFPerm)
endif
" the file has been changed outside of vim, enable reedit
mkview
silent edit!
let &fileformat = l:originalFileFormat
let &syntax = &syntax
silent loadview
elseif g:jsonnet_fmt_fail_silently == 0
" FixMe: We could leverage the errors coming from the `jsonnetfmt` and
" give immediate feedback to the user at every save time.