Skip to content

Commit

Permalink
move textobj_include_function_doc to getter function
Browse files Browse the repository at this point in the history
  • Loading branch information
bhcleek committed Mar 27, 2018
1 parent 9b912d1 commit 0c2893d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 4 additions & 0 deletions autoload/go/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ function! go#config#GorenamePrefill() abort
\ ': go#util#camelcase(expand("<cword>"))')
endfunction

function! go#config#TextobjIncludeFunctionDoc() abort
return get(g:, "go_textobj_include_function_doc", 1)
endfunction

" Set the default value. A value of "1" is a shortcut for this, for
" compatibility reasons.
if exists("g:go_gorename_prefill") && g:go_gorename_prefill == 1
Expand Down
12 changes: 4 additions & 8 deletions autoload/go/textobj.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
if !exists("g:go_textobj_include_function_doc")
let g:go_textobj_include_function_doc = 1
endif

if !exists("g:go_textobj_include_variable")
let g:go_textobj_include_variable = 1
endif
Expand Down Expand Up @@ -33,7 +29,7 @@ function! go#textobj#Function(mode) abort
let command = printf("%s -format vim -file %s -offset %s", bin_path, fname, offset)
let command .= " -mode enclosing"

if g:go_textobj_include_function_doc
if go#config#TextobjIncludeFunctionDoc()
let command .= " -parse-comments"
endif

Expand All @@ -59,7 +55,7 @@ function! go#textobj#Function(mode) abort
if a:mode == 'a'
" anonymous functions doesn't have associated doc. Also check if the user
" want's to include doc comments for function declarations
if has_key(info, 'doc') && g:go_textobj_include_function_doc
if has_key(info, 'doc') && go#config#TextobjIncludeFunctionDoc()
call cursor(info.doc.line, info.doc.col)
elseif info['sig']['name'] == '' && g:go_textobj_include_variable
" one liner anonymous functions
Expand Down Expand Up @@ -121,7 +117,7 @@ function! go#textobj#FunctionLocation(direction, cnt) abort
let command .= ' -mode prev'
endif

if g:go_textobj_include_function_doc
if go#config#TextobjIncludeFunctionDoc()
let command .= " -parse-comments"
endif

Expand Down Expand Up @@ -186,7 +182,7 @@ function! go#textobj#FunctionJump(mode, direction) abort
endif

if a:mode == 'v' && a:direction == 'prev'
if has_key(info, 'doc') && g:go_textobj_include_function_doc
if has_key(info, 'doc') && go#config#TextobjIncludeFunctionDoc()
keepjumps call cursor(info.doc.line, 1)
else
keepjumps call cursor(info.func.line, 1)
Expand Down

0 comments on commit 0c2893d

Please sign in to comment.