diff options
Diffstat (limited to 'misc/vim/ftplugin/go/fmt.vim')
-rw-r--r-- | misc/vim/ftplugin/go/fmt.vim | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/misc/vim/ftplugin/go/fmt.vim b/misc/vim/ftplugin/go/fmt.vim index 30814fdfd..5f7976f5f 100644 --- a/misc/vim/ftplugin/go/fmt.vim +++ b/misc/vim/ftplugin/go/fmt.vim @@ -12,15 +12,35 @@ " It tries to preserve cursor position and avoids " replacing the buffer with stderr output. " +" Options: +" +" g:go_fmt_commands [default=1] +" +" 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") finish endif -command! -buffer Fmt call s:GoFormat() +if !exists("g:go_fmt_commands") + let g:go_fmt_commands = 1 +endif + +if !exists("g:gofmt_command") + let g:gofmt_command = "gofmt" +endif + +if g:go_fmt_commands + command! -buffer Fmt call s:GoFormat() +endif function! s:GoFormat() let view = winsaveview() - silent %!gofmt + silent execute "%!" . g:gofmt_command if v:shell_error let errors = [] for line in getline(1, line('$')) |