fatih / vim-go

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

Calling :GoImports sometimes yields "Error detected while processing function <SNR>79_highlightMatches[10]..go#util#HighlightPositions" #2890

Closed antoineco closed 4 years ago

antoineco commented 4 years ago

What did you do?

Ran :GoImports on the following file:

package eventsource

type Indexer interface {
        Get(region string) *eventbridge.EventSource
}

The expected import is github.com/aws/aws-sdk-go/service/eventbridge. The module is already present in go.mod and pre-cached.

What did you expect to happen?

:GoImports runs silently and without error.

What happened instead?

Upon calling :GoImports, the following error message is printed

Error detected while processing function <SNR>79_highlightMatches[10]..go#util#HighlightPositions:
line   32:
E964: Invalid column number: 6
Press ENTER or type command to continue

After pressing ENTER, the buffer is refreshed and the import is added despite the error.

It does not happen consistently, but often enough, more often(?) on new files.

Configuration:

vim-go version:

7fef39e

vimrc you used to reproduce:

vimrc
" ================== Vim-Go ==================

let g:go_highlight_function_arguments = 1    " highlight function and method declarations, as well as variable names
                                             " in arguments and return values in function declarations
let g:go_highlight_function_calls = 1        " highlight function and method calls
let g:go_highlight_variable_declarations = 1 " highlight variable names in variable declarations

let g:go_rename_command = 'gopls' " rename using gopls instead of gorename

let g:go_echo_command_info = 0 " disable echoing of commands, redundant with status bar

" ================== Formatting ==================

filetype plugin on " load filetype specific plugins
filetype indent on " load filetype specific indentations
set autoindent     " auto indentation
set smarttab       " better blank insertion
set nojoinspaces   " single space after punctuation

" ====================== UI ======================

syntax enable         " syntax highlighting
set number            " display line numbers
set display+=lastline " do not truncate long last line
set scrolloff=5       " number of lines to show above/below cursor
set showcmd           " show command in the last line of the screen
set laststatus=2      " always show status line
set colorcolumn=+1    " highlight textwidth column

" ================== Behaviour ===================

let mapleader=','                    " more accessible leader key
set backspace=indent,eol,start       " allow backspacing in Insert mode
set listchars=tab:>\ ,trail:-,nbsp:+ " characters used in list mode
set splitbelow                       " open horizontal split below
set splitright                       " open vertical split to the right
set wildmenu                         " enhanced command completion
set wildmode=list:longest,list:full  " 1st Tab completes till longest common string, 2nd opens wildmenu
set incsearch                        " highlight searched pattern while typing
set hlsearch                         " keep matches from previous search highlighted
set smartcase                        " make search case sensitive when pattern contains uppercase chars
set ignorecase                       " required by smartcase
set autoread                         " re-read files changed outside of Vim
set ttimeout                         " wait for character after Esc
set ttimeoutlen=50                   " shorten wait for key sequence after Esc
set mouse=                           " disable mouse support
set autowrite                        " automatically write buffer on commands like :next
packadd! matchit                     " improve % command

" start new undo sequence after a newline or C-U in insert mode
inoremap  u
inoremap  u

" use Space to toggle/create folds
nnoremap    foldlevel('.')?'za':''
vnoremap  zf

Vim version:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 15 2020 06:40:31)
Included patches: 1-2269
Modified by team+vim@tracker.debian.org

Go version:

go version go1.14.2 linux/amd64

Go environment

go env Output:
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/acotten/.cache/go-build"
GOENV="/home/acotten/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/acotten/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/acotten/go/src/myproject/go.mod"
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-build724078314=/tmp/go-build -gno-record-gcc-switches"

gopls version

gopls version Output:
golang.org/x/tools/gopls 0.4.1
    golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=
bhcleek commented 4 years ago

Thank you for reporting. I've also seen this and will get a PR up this weekend to resolve it. Would you be wiling to help test it since there isn't a reliable reproduction path?

antoineco commented 4 years ago

Sure, happy to help however I can, I usually run from master anyway.

bhcleek commented 4 years ago

https://github.com/fatih/vim-go/pull/2892 is ready for you to try. I'll be using it over the next week, too, to make sure it resolves the problem as expected.

antoineco commented 4 years ago

So far so good @bhcleek