fatih / vim-go

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

Startup time ~4 s on nvim, macos, even with empty init.lua #3642

Closed greg-bell closed 4 months ago

greg-bell commented 4 months ago

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

Ran neovim main.go

What did you expect to happen?

Fast startup time.

What happened instead?

Startup time ~4 s.

Problem seems to be commands.vim?

030.256  000.129  000.129: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/compiler/go.vim
030.440  000.014  000.014: sourcing /usr/local/Cellar/neovim/0.9.5/share/nvim/runtime/compiler/go.vim
030.661  000.759  000.616: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/ftplugin/go.vim
031.662  000.210  000.210: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/autoload/go/package.vim
032.230  000.105  000.105: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/autoload/go/path.vim
2565.397  2534.304  2533.989: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/ftplugin/go/commands.vim
2565.826  000.270  000.270: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/ftplugin/go/mappings.vim
2566.044  000.089  000.089: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/ftplugin/go/snippets.vim
2566.435  000.265  000.265: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/ftplugin/go/tagbar.vim
2566.638  000.013  000.013: sourcing /usr/local/Cellar/neovim/0.9.5/share/nvim/runtime/ftplugin/go.vim
2567.742  000.075  000.075: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/indent/go.vim
2567.905  000.013  000.013: sourcing /usr/local/Cellar/neovim/0.9.5/share/nvim/runtime/indent/go.vim
2569.139  000.950  000.950: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/syntax/go.vim
2569.312  000.015  000.015: sourcing /usr/local/Cellar/neovim/0.9.5/share/nvim/runtime/syntax/go.vim
2570.446  000.810  000.810: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/autoload/go/lsp.vim
2571.210  000.229  000.229: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/autoload/go/job.vim
3446.136  000.402  000.402: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/autoload/go/lsp/message.vim
3446.565  000.082  000.082: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/autoload/go/uri.vim
4294.271  000.082  000.082: sourcing /Users/greg.bell/.local/share/nvim/site/pack/plugins/start/vim-go/autoload/go/statusline.vim

Configuration (MUST fill this out):

vim-go version:

master/0e97556 but problem has existed on other versions.

vimrc you used to reproduce:

vimrc ```vim empty ```

Vim version (first three lines from :version):

NVIM v0.9.5 Build type: Release LuaJIT 2.1.1703358377

Go version (go version):

go version go1.22.0 darwin/amd64

Go environment

go env Output:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/greg.bell/Library/Caches/go-build'
GOENV='/Users/greg.bell/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/greg.bell/.asdf/installs/golang/1.22.0/packages/pkg/mod'
GONOPROXY='github.com/x/*'
GONOSUMDB='github.com/x/*'
GOOS='darwin'
GOPATH='/Users/greg.bell/.asdf/installs/golang/1.22.0/packages'
GOPRIVATE='github.com/x/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/greg.bell/.asdf/installs/golang/1.22.0/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/greg.bell/.asdf/installs/golang/1.22.0/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/greg.bell/wrk/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/4t/w5fzqr_s6kjcwsdk5922y0xh0000gp/T/go-build1881724599=/tmp/go-build -gno-record-gcc-switches -fno-common'

gopls version

gopls version Output:

golang.org/x/tools/gopls v0.14.2
    golang.org/x/tools/gopls@v0.14.2 h1:sIw6vjZiuQ9S7s0auUUkHlWgsCkKZFWDHmrge8LYsnc=

vim-go configuration:

vim-go configuration
g:go_metalinter_command = 'golangci-lint'
g:go_metalinter_enabled = ''
g:go_jump_to_error = 1
g:go_loaded_gosnippets = 1
g:go_loaded_install = 1
g:go_def_mapping_enabled = 0

filetype detection configuration:

filetype detection
filetype detection:ON  plugin:ON  indent:ON
bitwombat commented 4 months ago

Turned out to be asdf's extremely slow performance (even though it's not slow on the command line). See https://github.com/asdf-vm/asdf/issues/290 for details. Workaround is to add this to .bashrc:

function unshim() {
  PATH=$(asdf where golang)/go/bin:$PATH
}

I've had related problems before and asdf's direnv plugin works too.

startuplog had weird output, so finding this was mostly an educated guess and lots of echomsg statements (with reltime).