Skip to content

'await' function in autoload/go/promise.vim takes a lot of time while saving a file #3286

Closed
@suhas-bn-1412

Description

@suhas-bn-1412

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

I have installed vim-go as a plugin for my vim. After I edit any go files, and save and quit vim, it takes very long time to close.

What did you expect to happen?

I expected it to close immediately

What happened instead?

It takes lot of time as long as 44 seconds to quit

This was the log printed in the vim profile I created. We can see that await functions runs for 17 seconds.

FUNCTION  <SNR>95_await()
    Defined: ~/.vim/plugged/vim-go/autoload/go/promise.vim:37
Called 2 times
Total time:  17.197947
 Self time:  17.194680

count  total (s)   self (s)
    2              0.000018   let l:timer = timer_start(a:timeout, function('s:setretval', [a:default], self))
  345              0.001395   while !has_key(self, 'retval')
  343  17.195654  17.192387     sleep 50m
  345              0.000717   endwhile
    2              0.000006   call timer_stop(l:timer)

    2              0.000004   if get(self, 'exception', 0)
                                throw self.retval
    2              0.000001   endif
    2              0.000003   return self.retval

How can I resolve this?

Configuration (MUST fill this out):

vim-go version: v1.25

vimrc you used to reproduce:

vimrc
" install vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
 silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
   \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
 autocmd VimEnter * PlugInstall --sync | source ~/.vimrc
endif

"------------------------------------------------------------------------------
" Plug installed plugins

call plug#begin('~/.vim/plugged')

" Golang syntax highlighting, auto completions
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }

" NERDtree for file browsing
Plug 'preservim/nerdtree'

" CtrlP for fuzzy file search
Plug 'ctrlpvim/ctrlp.vim'

" Botton line (vim status bar)
Plug 'itchyny/lightline.vim'

" Vim-fugitive for git workflow
Plug 'tpope/vim-fugitive'

" Color scheme
Plug 'gryf/wombat256grf'

call plug#end()
"------------------------------------------------------------------------------

" Turn on syntax highlighting
syntax on

" Backapce should work over everything
set backspace=indent,eol,start

" Show line numbers
set number

" tab uses this many spaces
set tabstop=8

" Status bar
set laststatus=2

" Last line
set showmode
set showcmd

" colorscheme
colorscheme wombat256grf
"colorscheme monokai

" Any vertical splits to happen on right
set splitright

" Any horizontal splits to happen at bottom
set splitbelow


" Enable to copy to clipboard for operations like yank, delete, change and put
" http://stackoverflow.com/questions/20186975/vim-mac-how-to-copy-to-clipboard-without-pbcopy
if has('unnamedplus')
  set clipboard^=unnamed
  set clipboard^=unnamedplus
endif

" This enables us to undo files even if you exit Vim.
if has('persistent_undo')
  set undofile
  set undodir=~/.config/vim/tmp/undo//
endif

" Turn on highlighting for searched string
set hls

" Set output encoding shown in terminal  to utf-8 ()
set encoding=utf-8

" Set file encoding to utf-8
set fileencoding=utf-8


"------------------------------------------------------------------------------
" User defined commands
"
" Command to see the changes done in current session
" template: coomand <desired_alias> <vim_command>
command Diff w !diff % -    " Show changes that are not written yet
"------------------------------------------------------------------------------


"------------------------------------------------------------------------------
" NERDtree
nnoremap <F1> :NERDTreeToggle<CR>
nnoremap <F2> :NERDTree<CR>
let g:NERDTreeDirArrowExpandable = '>'
let g:NERDTreeDirArrowCollapsible = '^'
"------------------------------------------------------------------------------



"------------------------------------------------------------------------------
" lightline -> status bar
if !has('gui_running')
          set t_Co=256
endif
let g:lightline = {
      \ 'colorscheme': 'wombat',
      \ 'active': {
      \   'left': [ [ 'mode', 'paste' ],
      \             [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
      \ },
      \ 'component_function': {
      \   'gitbranch': 'FugitiveHead'
      \ },
      \ }
"------------------------------------------------------------------------------



"------------------------------------------------------------------------------
" gopls
let g:go_def_mode='godef'
let g:go_info_mode='gopls'
" vim slows down because of vim-go
let g:go_debug=['shell-commands']
"------------------------------------------------------------------------------



"------------------------------------------------------------------------------
" Solve any issues caused by plugins
"
"
" Vim taking time to load
" https://stackoverflow.com/questions/14635295/vim-takes-a-very-long-time-to-start-up
set clipboard=exclude:.*
"------------------------------------------------------------------------------

Vim version (first three lines from :version):

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 8 2021 09:58:42)

Go version (go version):

go version go1.13.7 linux/amd64

Go environment

go env Output:
GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/snataraj/go//bin/"
GOCACHE="/home/snataraj/.cache/go-build"
GOENV="/home/snataraj/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/snataraj/go/"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/net/wtl-netapp-2/vol/VIEW/swbuild_snap_view/vobs/fw-tools/gitrepos_data/golang_master_1/golang-1.13.7"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/net/wtl-netapp-2/vol/VIEW/swbuild_snap_view/vobs/fw-tools/gitrepos_data/golang_master_1/golang-1.13.7/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build641193532=/tmp/go-build -gno-record-gcc-switches"

gopls version

gopls version Output:
golang.org/x/tools/gopls v0.6.11
    golang.org/x/tools/[email protected] h1:7S2k0xuVYc3secjy2uz0n+fGYxGJU6gXsLOmQ/r1HoI=

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions