123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- let s:got_fmt_error = 0
- function! go#asmfmt#Format() abort
-
- let l:curw = winsaveview()
-
- let l:tmpname = tempname()
- call writefile(go#util#GetLines(), l:tmpname)
-
- let path = go#path#CheckBinPath("asmfmt")
- if empty(path)
- return
- endif
- let out = go#util#System(path . ' -w ' . l:tmpname)
-
- if go#util#ShellError() == 0
-
- try | silent undojoin | catch | endtry
-
- let old_fileformat = &fileformat
-
- let original_fperm = getfperm(expand('%'))
- call rename(l:tmpname, expand('%'))
-
- call setfperm(expand('%'), original_fperm)
- silent edit!
- let &fileformat = old_fileformat
- let &syntax = &syntax
- endif
-
- call winrestview(l:curw)
- endfunction
- function! go#asmfmt#ToggleAsmFmtAutoSave() abort
- if get(g:, "go_asmfmt_autosave", 0)
- let g:go_asmfmt_autosave = 1
- call go#util#EchoProgress("auto asmfmt enabled")
- return
- end
- let g:go_asmfmt_autosave = 0
- call go#util#EchoProgress("auto asmfmt disabled")
- endfunction
|