fatih / vim-go

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

No AST for new files #2487

Closed CalebLarsen closed 5 years ago

CalebLarsen commented 5 years ago

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

Frequently I will make a new go file or read somebody else's code, and then attempt to use :GoDef on functions and have the function fail. The error I get is that there is no AST for that file. I've tried to search how to resolve this issue and have not found any resolutions (although I found another soul on reddit had similar issues).

Try creating new files, or copy a file from Github and immediately running :GoDef

What did you expect to happen?

I expected to see the function definition

What happened instead?

I received an error of "vim-go: no AST for file:///path/to/file.go"

Configuration (MUST fill this out):

Vim in Tmux using Alacritty (I hope this is what you are wanting here)

vim-go version:

Latest (Updated to latest using vim plugged)

vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):

vimrc
"Error exists with this vimrc
" vim plug
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
call plug#end()

" set file specific things on
filetype on
filetype plugin on
filetype indent on

" vim-go
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_build_constraints = 1 " highlighting for go
let g:go_fmt_command = "goimports"
let g:go_addtags_transform = "camelcase"
let g:go_auto_type_info = 1 " show type info in status bar
inoremap iee :GoIfErr

set ts=4 sw=4 ai
set tabstop=4
set expandtab
set t_Co=256

Vim version (first three lines from :version):

VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 3 2019 19:23:34) Included patches: 1-1968 Compiled by Arch Linux

Go version (go version):

go version go1.13 linux/amd64

Go environment

go env Output:

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/caleb/.cache/go-build"
GOENV="/home/caleb/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/caleb/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="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-build202486796=/tmp/go-build -gno-record-gcc-switches"

vim-go configuration:

vim-go configuration
g:go_auto_type_info = 1
g:go_highlight_extra_types = 1
g:go_highlight_operators = 1
g:go_highlight_fields = 1
g:go_loaded_gosnippets = 1
g:go_addtags_transform = 'camelcase'
g:go_highlight_functions = 1
g:go_jump_to_error = 1
g:go_highlight_types = 1
g:go_fmt_command = 'goimports'
g:go_highlight_methods = 1
g:go_highlight_build_constraints = 1
g:go_loaded_install = 1
bhcleek commented 5 years ago

The default for g:go_def_mode is gopls, which requires that the file is on disk, so just save the file before trying to jump to a definition.

This will be remedied in a future version of gopls.

Alternatively, if you're in GOPATH mode, then you can set g:go_def_mode to godef or guru.

hellodudu commented 5 years ago

Same problem, using godef can solve this. But it's much more slower when jumping.