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

Auto imports not working #3630

Closed
tlafebre opened this issue Jan 11, 2024 · 1 comment
Closed

Auto imports not working #3630

tlafebre opened this issue Jan 11, 2024 · 1 comment

Comments

@tlafebre
Copy link

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)

  • Re-installed Go 1.21.6
  • Re-installed Vim 9.0
  • Re-installed go.vim
  • Ran :GoInstallBinaries
  • Tried several package managers (Pathogen and VIM packages) to install go.vim

Steps:

  • mkdir test
  • cd test
  • go mod init main
  • vim main.go
  • delete 'import "fmt"' line
  • save file

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:

5bed70d - (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
Copy link
Collaborator

bhcleek commented Jan 11, 2024

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.

@bhcleek bhcleek closed this as completed Jan 24, 2024
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

2 participants