Skip to content

Commit

Permalink
move fmt_options to getter function
Browse files Browse the repository at this point in the history
  • Loading branch information
bhcleek committed Mar 27, 2018
1 parent 69eaaf1 commit e6e72dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 4 additions & 0 deletions autoload/go/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 3 additions & 7 deletions autoload/go/fmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, " "))

Expand Down

0 comments on commit e6e72dc

Please sign in to comment.