diff --git a/autoload/go/config.vim b/autoload/go/config.vim index 4469a84b57..d8c2d7496b 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -312,4 +312,8 @@ function! go#config#FmtCommand() abort return get(g:, "go_fmt_command", "gofmt") endfunction +function! go#config#FmtOptions() abort + return get(g:, "go_fmt_options", {}) +endfunction + " vim: sw=2 ts=2 et diff --git a/autoload/go/fmt.vim b/autoload/go/fmt.vim index da5755819f..3e6da96913 100644 --- a/autoload/go/fmt.vim +++ b/autoload/go/fmt.vim @@ -5,10 +5,6 @@ " fmt.vim: Vim command to format Go files with gofmt (and gofmt compatible " toorls, such as goimports). -if !exists('g:go_fmt_options') - let g:go_fmt_options = '' -endif - if !exists('g:go_fmt_fail_silently') let g:go_fmt_fail_silently = 0 endif @@ -182,9 +178,9 @@ function! s:fmt_cmd(bin_name, source, target) " add the options for binary (if any). go_fmt_options was by default of type " string, however to allow customization it's now a dictionary of binary " name mapping to options. - let opts = g:go_fmt_options - if type(g:go_fmt_options) == type({}) - let opts = has_key(g:go_fmt_options, a:bin_name) ? g:go_fmt_options[a:bin_name] : "" + let opts = go#config#FmtOptions() + if type(opts) == type({}) + let opts = has_key(opts, a:bin_name) ? opts[a:bin_name] : "" endif call extend(cmd, split(opts, " "))