mirror of https://github.com/golang/go.git
misc/vim: add a gofmt_command flag for :Fmt
R=dsymonds, dominik.honnef, n13m3y3r, rsc, kamil.kisiel CC=golang-dev https://golang.org/cl/22940044
This commit is contained in:
parent
8f10c76471
commit
c4f5421bc7
|
|
@ -18,15 +18,21 @@
|
||||||
"
|
"
|
||||||
" Flag to indicate whether to enable the commands listed above.
|
" Flag to indicate whether to enable the commands listed above.
|
||||||
"
|
"
|
||||||
|
" g:gofmt_command [default="gofmt"]
|
||||||
|
"
|
||||||
|
" Flag naming the gofmt executable to use.
|
||||||
|
"
|
||||||
if exists("b:did_ftplugin_go_fmt")
|
if exists("b:did_ftplugin_go_fmt")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
if !exists("g:go_fmt_commands")
|
if !exists("g:go_fmt_commands")
|
||||||
let g:go_fmt_commands = 1
|
let g:go_fmt_commands = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !exists("g:gofmt_command")
|
||||||
|
let g:gofmt_command = "gofmt"
|
||||||
|
endif
|
||||||
|
|
||||||
if g:go_fmt_commands
|
if g:go_fmt_commands
|
||||||
command! -buffer Fmt call s:GoFormat()
|
command! -buffer Fmt call s:GoFormat()
|
||||||
|
|
@ -34,7 +40,7 @@ endif
|
||||||
|
|
||||||
function! s:GoFormat()
|
function! s:GoFormat()
|
||||||
let view = winsaveview()
|
let view = winsaveview()
|
||||||
silent %!gofmt
|
silent execute "%!" . g:gofmt_command
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
let errors = []
|
let errors = []
|
||||||
for line in getline(1, line('$'))
|
for line in getline(1, line('$'))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue