From 4c6513e6946191dc13c232ed7491d6325dcd381c Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Wed, 5 Jun 2024 11:42:42 +0100 Subject: [PATCH 1/3] feat: add config to exclude certain binaries from updating Signed-off-by: Elias Van Ootegem --- autoload/go/config.vim | 4 ++++ doc/vim-go.txt | 43 +++++++++++++++++++++++++++++++++++++++++- plugin/go.vim | 5 +++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/autoload/go/config.vim b/autoload/go/config.vim index 241551fa52..32ee06db61 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -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': ''}, diff --git a/doc/vim-go.txt b/doc/vim-go.txt index e2e4ec3d73..be58d40762 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -512,6 +512,7 @@ CTRL-t syntax to the binary name. e.g. `:GoInstallBinaries gopls@v0.9.1`. Set |'g:go_get_update'| to disable updating dependencies. + Set |'g:go_exclude_binaries'| to disable installing specific binaries. *:GoUpdateBinaries* :GoUpdateBinaries [binaries] @@ -525,6 +526,7 @@ CTRL-t syntax to the binary name. e.g. `:GoUpdateBinaries gopls@v0.9.1`. Set |'g:go_get_update'| to disable updating dependencies. + Set |'g:go_exclude_binaries'| to disable updating specific binaries. *:GoImplements* :GoImplements @@ -2489,7 +2491,7 @@ 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 '>'. @@ -2497,6 +2499,45 @@ 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|. 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* diff --git a/plugin/go.vim b/plugin/go.vim index 30651a9167..36d55677b9 100644 --- a/plugin/go.vim +++ b/plugin/go.vim @@ -132,6 +132,11 @@ function! s:GoInstallBinaries(updateBinaries, ...) let l:packages = s:packages endif + " Filter packages from exclude list + for l:bin in go#config#GoExcludeBinaries() + call remove(l:bin, l:packages) + endfor + let l:platform = '' if go#util#IsWin() let l:platform = 'windows' From a38c93ffe4f75ef85be0b69c13db46f1bcb71fd8 Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Fri, 7 Jun 2024 12:01:15 +0100 Subject: [PATCH 2/3] fix: allow command args to override config excluded binaries Signed-off-by: Elias Van Ootegem --- doc/vim-go.txt | 5 +++-- plugin/go.vim | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/vim-go.txt b/doc/vim-go.txt index be58d40762..22fee18b0a 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -2502,8 +2502,9 @@ Set the sign text used for breakpoints in the debugger. By default it's '>'. *'g:go_exclude_binaries'* Set a list of binaries to exclude from installing/updating when running either -|:GoInstallBinaries| or |:GoUpdateBinaries|. Possible values are all keys used -in the `s:packages` dictionary: +|:GoInstallBinaries| or |:GoUpdateBinaries| without specifying a specific +binary. This list is ignored when installing or updating specific binaries to +specific versions. Possible values are all keys used in the `s:packages` dictionary: > let g:go_exclude_binaries = [ diff --git a/plugin/go.vim b/plugin/go.vim index 36d55677b9..f130b9260e 100644 --- a/plugin/go.vim +++ b/plugin/go.vim @@ -130,12 +130,13 @@ 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 endif - " Filter packages from exclude list - for l:bin in go#config#GoExcludeBinaries() - call remove(l:bin, l:packages) - endfor let l:platform = '' if go#util#IsWin() From f682b14e948b9ae06b0f7ffe69aa483d0c023ff6 Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Fri, 7 Jun 2024 12:37:23 +0100 Subject: [PATCH 3/3] fix: doc line length (linter) Signed-off-by: Elias Van Ootegem --- doc/vim-go.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/vim-go.txt b/doc/vim-go.txt index 22fee18b0a..1bda1d6c54 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -2502,9 +2502,9 @@ Set the sign text used for breakpoints in the debugger. By default it's '>'. *'g:go_exclude_binaries'* Set a list of binaries to exclude from installing/updating when running either -|:GoInstallBinaries| or |:GoUpdateBinaries| without specifying a specific -binary. This list is ignored when installing or updating specific binaries to -specific versions. Possible values are all keys used in the `s:packages` dictionary: +|: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 = [