fatih / vim-go

Go development plugin for Vim
https://www.patreon.com/bhcleek
Other
15.9k stars 1.45k forks source link

Auto imports not working #3630

Closed tlafebre closed 5 months ago

tlafebre commented 5 months ago

Suddenly, my auto imports stopped working for new go projects. For existing projects, it appears to be working still. I have searched for this issue on the internet and in the troubleshooting but couldn't get a clear answer. The only thing I recently did (in this context) was updating to go version 1.21.6

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

Steps:

What did you expect to happen?

I expected vim.go to add 'import "fmt"' when saving the file.

What happened instead?

It didn't add the import line. It did however remove the the newline that was present (so the formatter worked)

Configuration (MUST fill this out):

vim-go version:

5bed70de - (3 days ago) Merge pull request #3628 from bhcleek/revive/unpin - Billie Cleek (HEAD -> master, origin/master, origin/HEAD)

vimrc you used to reproduce:

syntax on execute pathogen#infect() filetype plugin indent on let mapleader = "," "Go: au FileType go nmap r :GoRun au FileType go nmap b :GoBuild au FileType go nmap t :GoTest au FileType go nmap d :GoDoc au FileType go nmap cw :GoRename

Vim version (first three lines from :version):

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Nov 12 2023 01:15:20) macOS version - x86_64 Included patches: 1-2018

Go version (go version):

go version go1.21.6 darwin/amd64

Go environment

go env Output:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/user/Library/Caches/go-build'
GOENV='/Users/user/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/user/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/user/go.mod'
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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/1c/tcpf2y_118x2_f1jc42zh7lc0000gq/T/go-build158379205=/tmp/go-build -gno-record-gcc-switches -fno-common'

gopls version

gopls version Output:


bhcleek commented 5 months ago

Re-installed go.vim

I'm not able to duplicate this. Can you try running :GoUpdateBinaries to update the binaries? :GoInstallBinaries only installs missing binaries; it doesn't update binaries that already exist the way :GoUpdateBinaries does.

If that doesn't resolve the problem, then please execute :let g:go_debug=['lsp'] and provide the contents of the __GOLSP_LOG__ window.