Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config to exclude certain binaries from updating #3668

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions autoload/go/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ function! go#config#FillStructMode() abort
return get(g:, 'go_fillstruct_mode', 'fillstruct')
endfunction

function! go#config#GoExcludeBinaries() abort
return get(g:, 'go_exclude_binaries', [])
endfunction

function! go#config#DebugMappings() abort
let l:default = {
\ '(go-debug-continue)': {'key': '<F5>'},
Expand Down
44 changes: 43 additions & 1 deletion doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ CTRL-t
syntax to the binary name. e.g. `:GoInstallBinaries [email protected]`.

Set |'g:go_get_update'| to disable updating dependencies.
Set |'g:go_exclude_binaries'| to disable installing specific binaries.

*:GoUpdateBinaries*
:GoUpdateBinaries [binaries]
Expand All @@ -525,6 +526,7 @@ CTRL-t
syntax to the binary name. e.g. `:GoUpdateBinaries [email protected]`.

Set |'g:go_get_update'| to disable updating dependencies.
Set |'g:go_exclude_binaries'| to disable updating specific binaries.

*:GoImplements*
:GoImplements
Expand Down Expand Up @@ -2489,14 +2491,54 @@ Highlight the current line and breakpoints in the debugger.
let g:go_highlight_debug = 1
<

*'go:go_debug_breakpoint_sign_text'*
*'g:go_debug_breakpoint_sign_text'*

Set the sign text used for breakpoints in the debugger. By default it's '>'.

>
let g:go_debug_breakpoint_sign_text = '>'
<

*'g:go_exclude_binaries'*

Set a list of binaries to exclude from installing/updating when running either
|:GoInstallBinaries| or |:GoUpdateBinaries|. The list of excluded binaries is
ignored when specifying a specific binary/version to install or update to.
Possible values are all keys used in the `s:packages` dictionary:

>
let g:go_exclude_binaries = [
\ 'asmfmt',
\ 'dlv',
\ 'errcheck',
\ 'fillstruct',
\ 'godef',
\ 'goimports',
\ 'revive',
\ 'gopls',
\ 'golangci-lint',
\ 'staticcheck',
\ 'gomodifytags',
\ 'gorename',
\ 'gotags',
\ 'impl',
\ 'motion',
\ 'iferr',
\]
<

Default:

>
let g:go_exclude_binaries = []
<

To exclude, for example, `errcheck`, `dlv`, and `golangci-lint`:

>
let g:go_exclude_binaries = ['errcheck', 'dlv', 'golangci-lint']
<

==============================================================================
FAQ TROUBLESHOOTING *go-troubleshooting*

Expand Down
6 changes: 6 additions & 0 deletions plugin/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,14 @@ function! s:GoInstallBinaries(updateBinaries, ...)
endfor
else
let l:packages = s:packages
" Filter packages from exclude list, if no binaries were explicitly
" specified.
for l:bin in go#config#GoExcludeBinaries()
call remove(l:bin, l:packages)
endfor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l:packages needs to copy s:packages (use the copy or deepcopy) since entries are being removed so that s:packages is not altered.

Also, :GoInstallBinaries should probably not skip anything that's missing. I think that means that instead of this removal, the check around line 160 that currently reads

      if a:updateBinaries == 1
        echo "vim-go: Updating " . l:binary . ". Reinstalling ". importPath . " to folder " . go_bin_path

should probably be something like

      if a:updateBinaries == 1
        if index(go#config#GoExcludeBinaries(), l:bin) != -1
            echo "vim-go: Skipping out of date " . l:binary . ". "
            continue
        endif
        echo "vim-go: Updating " . l:binary . ". Reinstalling ". importPath . " to folder " . go_bin_path

endif


let l:platform = ''
if go#util#IsWin()
let l:platform = 'windows'
Expand Down
Loading