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

using custom tools to adjust imports #3692

Open
alcortesm opened this issue Nov 14, 2024 · 0 comments
Open

using custom tools to adjust imports #3692

alcortesm opened this issue Nov 14, 2024 · 0 comments

Comments

@alcortesm
Copy link

alcortesm commented Nov 14, 2024

What did you do? (required: The issue will be closed when not provided)

I tried running a custom tool to adjust imports, this is, a tool different than gopls or goimports.

I configured g:go_imports_mode to run my custom tool foo:

let g:go_imports_mode = 'foo'

Then I opened a Go file and ran :GoImports.

What did you expect to happen?

I expected vim to call the tool foo and pass it the path of the file to be adjusted as an argument.

The tool foo is a placeholder, in reality, the tool foo will be a script that runs goimports then cgi, but I don't think that is relevant to this issue.

What happened instead?

Vim called the gopls tool to adjust the imports.

This behavour is somewhat consistent with the documentation of 'g:go_imports_mode' which says:

Valid options are `goimports` and `gopls`. [...]. By default `gopls` is used.

So maybe this is not an issue but a feature request :).

Configuration (MUST fill this out):

vim-go version:

commit ec7a59e, which is the current master at the time of writing.

vimrc you used to reproduce:

; cat ~/.vim/vimrc
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
call plug#end()


; cat ~/.vim/after/ftplugin/go.vim
let g:go_imports_mode = 'foo'

Vim version (first three lines from :version):

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 04 2023 10:24:44)
Included patches: 1-1378, 1499
Modified by [email protected]

Go version (go version):

; go version
go version go1.23.2 linux/amd64

Go environment

go env Output:
; go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/alcortes/.cache/go-build'
GOENV='/home/alcortes/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/alcortes/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/alcortes/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/alcortes/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/alcortes/go/pkg/mod/golang.org/[email protected]/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.2'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/alcortes/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1625970927=/tmp/go-build -gno-record-gcc-switches'

gopls version

gopls version Output:
; gopls version
golang.org/x/tools/gopls v0.16.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant