Skip to content

Commit

Permalink
Merge pull request #573 from gonotes/master
Browse files Browse the repository at this point in the history
Add GoOracleTags command to set build tags for oracle
  • Loading branch information
fatih committed Nov 15, 2015
2 parents bf23118 + 51c482f commit 4817731
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
34 changes: 30 additions & 4 deletions autoload/go/oracle.vim
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,24 @@ func! s:RunOracle(mode, selected, needs_package) range abort
if empty(bin_path)
return
endif

if exists('g:go_oracle_tags')
let tags = get(g:, 'go_oracle_tags')
else
let tags = ""
endif

if a:selected != -1
let pos1 = s:getpos(line("'<"), col("'<"))
let pos2 = s:getpos(line("'>"), col("'>"))
let cmd = printf('%s -format plain -pos=%s:#%d,#%d %s',
let cmd = printf('%s -format plain -pos=%s:#%d,#%d -tags=%s %s',
\ bin_path,
\ shellescape(fname), pos1, pos2, a:mode)
\ shellescape(fname), pos1, pos2, tags, a:mode)
else
let pos = s:getpos(line('.'), col('.'))
let cmd = printf('%s -format plain -pos=%s:#%d %s',
let cmd = printf('%s -format plain -pos=%s:#%d -tags=%s %s',
\ bin_path,
\ shellescape(fname), pos, a:mode)
\ shellescape(fname), pos, tags, a:mode)
endif

" now append each scope to the end as Oracle's scope parameter. It can be
Expand Down Expand Up @@ -156,6 +162,26 @@ function! go#oracle#Scope(...)
endif
endfunction

function! go#oracle#Tags(...)
if a:0
if a:0 == 1 && a:1 == '""'
unlet g:go_oracle_tags
echon "vim-go: " | echohl Function | echon "oracle tags is cleared"| echohl None
else
let g:go_oracle_tags = a:1
echon "vim-go: " | echohl Function | echon "oracle tags changed to: '". g:go_oracle_tags ."'" | echohl None
endif

return
endif

if !exists('g:go_oracle_tags')
echon "vim-go: " | echohl Function | echon "oracle tags is not set"| echohl None
else
echon "vim-go: " | echohl Function | echon "current oracle tags: '". g:go_oracle_tags ."'" | echohl None
endif
endfunction

" Show 'implements' relation for selected package
function! go#oracle#Implements(selected)
let out = s:RunOracle('implements', a:selected, 0)
Expand Down
Empty file modified autoload/go/tool.vim
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions doc/vim-go.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,16 @@ COMMANDS *go-commands*
the variable |g:go_metalinter_command|. To override the maximum linters
execution time use |g:go_metalinter_deadline| variable.

*:GoOracleTags*
:GoOracleTags [tags]

Changes the custom |g:go_oracle_tags| setting and overrides it with the
given build tags. This command cooperate with GoReferrers command when
there exist mulitiple build tags in your project,then you can set one
of the build tags for GoReferrers to find more accurate.
The custom build tags is cleared (unset) if `""` is given. If no arguments
is given it prints the current custom build tags.


===============================================================================
MAPPINGS *go-mappings*
Expand Down
1 change: 1 addition & 0 deletions ftplugin/go/commands.vim
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ command! -range=% GoCallstack call go#oracle#Callstack(<count>)
command! -range=% GoFreevars call go#oracle#Freevars(<count>)
command! -range=% GoChannelPeers call go#oracle#ChannelPeers(<count>)
command! -range=% GoReferrers call go#oracle#Referrers(<count>)
command! -nargs=? GoOracleTags call go#oracle#Tags(<f-args>)

" tool
command! -nargs=0 GoFiles echo go#tool#Files()
Expand Down

0 comments on commit 4817731

Please sign in to comment.