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 metalinter autosave and gopls is slow #2958

Closed
hnnsgstfssn opened this issue Jul 12, 2020 · 3 comments · Fixed by #2960
Closed

Using metalinter autosave and gopls is slow #2958

hnnsgstfssn opened this issue Jul 12, 2020 · 3 comments · Fixed by #2960

Comments

@hnnsgstfssn
Copy link

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

Open a Go source file in a module, then save the file with g:go_metalinter_command=gopls and g:go_metalinter_autosave=1.

What did you expect to happen?

That it would take <1s or that the linter runs asyncronously.

What happened instead?

Input is frozen until the linter passes or fails. This takes ~10s (see profile.log). Manually running :GoMetaLinter takes a fraction of a second.

Configuration (MUST fill this out):

vim-go version: 7b43988 (master)

vimrc you used to reproduce:

vimrc
set nocompatible
call plug#begin('~/.config/nvim/plugged')
Plug 'fatih/vim-go', { 'branch': 'master', 'do': ':GoUpdateBinaries' }
call plug#end()
let g:go_metalinter_command = "gopls"
let g:go_metalinter_autosave = 1

Vim version (first three lines from :version):

NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5

Go version (go version):

go version go1.14.4 linux/amd64

Go environment

go env Output:
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/x/.cache/go-build"
GOENV="/home/x/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/x/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build306055507=/tmp/go-build -gno-record-gcc-switches"

gopls version

gopls version Output:
golang.org/x/tools/gopls 0.4.3
    golang.org/x/tools/[email protected] h1:irz7Q+XdHNECamFKbNWKvMV2Ak6zBbwdwbZndG4545I=
@bhcleek
Copy link
Collaborator

bhcleek commented Jul 12, 2020

The gopls logs will be the most useful here. Can you open the file, execute :let g:go_debug=['lsp'], save your file, and provide the complete contents of the resulting __GOLSP_LOG__ window here?

@hnnsgstfssn
Copy link
Author

Absolutely, I had to add let g:go_debug=['lsp'] to my vimrc for it to start gopls with debug enabled, instead of setting after starting the session. golsp.log is the resulting output after opening the file with debug enabled and then saving it.

FWIW the following steps recreates a minimal module that I'm using to test this.

mkdir a; cd a
go mod init a
cat <<EOF>main.go
package main

import "fmt"

func main() {
  fmt.Println("hello")
}
EOF

@bhcleek
Copy link
Collaborator

bhcleek commented Jul 12, 2020

Absolutely, I had to add let g:go_debug=['lsp'] to my vimrc for it to start gopls with debug enabled

FWIW, let g:go_debug=['lsp'] does not have to be in your vimrc. You can set it at any time to see the request and responses to sent to and received from gopls after it's set.

In any case, I think I see what's going on here. I should have some time improve the experience next weekend.

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

Successfully merging a pull request may close this issue.

2 participants