Skip to content

no ParseGoHandle for file #2628

@codcodog

Description

@codcodog

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

use gd go to a function define, but it failed.

The project use govendor instead of go mod, so there is no go.mod file.

What did you expect to happen?

Go to the function define.

What happened instead?

It failed: vim-go: no ParseGoHandle for file

Configuration (MUST fill this out):

vim-go version:

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

vimrc
" ============= Plug 配置 END =============
"
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 $MYVIMRC
endif

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

" tab对齐
Plug 'godlygeek/tabular'

" 括号成对
Plug 'chun-yang/auto-pairs'

" Python 语法高亮
Plug 'hdima/python-syntax', {'for': 'python'}
" Python 缩进
Plug 'hynek/vim-python-pep8-indent', {'for': 'python'}
" Python 查看缩进
Plug 'Yggdroot/indentLine'

" markdown编辑器及其实时查看
Plug 'plasticboy/vim-markdown', {'for': 'markdown'}
Plug 'suan/vim-instant-markdown', {'for': 'markdown'}

" 前端emmet插件
Plug 'mattn/emmet-vim', {'for': ['html', 'vue']}

" 查看目录结构
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}

" 函数列表
Plug 'majutsushi/tagbar', {'on': 'TagbarToggle'}

" fuzzy finding
Plug 'junegunn/fzf.vim'

" vue
Plug 'posva/vim-vue'

Plug 'SirVer/ultisnips'

" theme
Plug 'morhetz/gruvbox'
Plug 'dracula/vim', { 'as': 'dracula' }

" go
Plug 'fatih/vim-go', {'for': 'go'}

Plug 'Valloric/YouCompleteMe'
"
" List ends here. Plugins become visible to Vim after this call.
call plug#end()
"
" ============= Plug 配置 END =============
"
"
"
" ============= Theme 配置 START ==========
"
set termguicolors
syntax on

syntax sync minlines=50
set synmaxcol=300 " stop syntax highlighting this many columns out
nnoremap :syntax sync fromstart

let g:gruvbox_contrast_dark = 'hard'
set background=dark
colorscheme gruvbox

" 覆盖 gruvbox 主题颜色设置
augroup DIY
autocmd!
autocmd ColorScheme * highlight Normal ctermbg=NONE guibg=#1d1f21
autocmd ColorScheme * highlight CursorLine ctermbg=NONE guibg=#26292b
autocmd WinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
autocmd ColorScheme * highlight! link Visual CursorLine
autocmd InsertEnter * highlight ColorColumn ctermbg=NONE guibg=#1a1b1d
autocmd InsertLeave * highlight ColorColumn ctermbg=NONE guibg=NONE
autocmd InsertEnter * let &colorcolumn=join(range(121, 999), ',')
autocmd InsertLeave * let &colorcolumn=0
augroup END
"
" ============= Theme 配置 END =============
"
"
"
" ============= Options 配置 START =============
"
set expandtab " 设置tab键换空格
set tabstop=4 " 设置tab键的宽度
set encoding=utf-8 " 设置字符编码
set shiftwidth=4 " 换行时行间交错使用4个空格
set autoindent " 自动对齐
set cindent " 自动缩进4空格
set smartindent " 智能自动缩进
set number " 设置行号
set rnu " 相对行号
set hlsearch " 开启高亮显示结果
set noincsearch " 不实时查找
set wrapscan " 查找到底部重新回到头部
set tags=tags;/ " 设置ctags, vim在当前目录找不到tags文件时请到上层目录查找。
set splitright " 设置vsplit在右边
set laststatus=2 " 总是显示状态栏
set directory=/tmp " 设置swp文件存储目录
set cscopetag " 开启 cscope
set cursorline " 高亮当前行

set statusline=%t " 文件名
set statusline+=%4m%r%w " modified flag, Modified, Readonly ?
set statusline+=%= " 切换到右边
set statusline+=%{toupper(&ff).'·'} " file format
set statusline+=%{toupper(strlen(&fenc)?&fenc:'none')} " file encoding
set statusline+=%8(%l,%c%) " line and column
set statusline+=%5P " Percentage through file of displayed window
"
" ============= Options 配置 END =============
"
"
"
" ============= BASIC 映射键 配置 START =============
inoremap jj
inoremap
inoremap
noremap j
noremap k
noremap W
noremap w
nnoremap :vertical resize +2
nnoremap :vertical resize -2
nnoremap :resize -2
nnoremap :resize +2
cnoremap w!! w !sudo tee > /dev/null %
cnoremap
cnoremap
cnoremap
exe "set =\eb"
exe "set =\ef"
cnoremap
cnoremap
tnoremap N
noremap <C-]> :MultiTag
noremap
"
" ============= BASIC 映射键 配置 END =============
"
"
"
" ============= 配置 START =============
"
let mapleader=',' " 设置 键
noremap w :update
noremap o :only
noremap v :vsp
noremap s :spk
noremap q :quit
noremap d :bw
vnoremap a :Tab/=
vnoremap > :Tab/=>
noremap n :noh
noremap , :vsplit $MYVIMRC:normal 107Gzz
noremap . :source $MYVIMRC
noremap c :vertical terminal
"
" ============= 配置 END ==============
"
"
"
" ============= 自定义命令配置 START =============
"
" buffers management
command! Only call OnlyCurrentBufferCodcodog()

" dependent on fzf plugin
command! -bang -nargs=* MultiTag call multitag()

function! s:multitag(query)
let pattern = '^'.a:query.'$'
let tags = taglist(pattern)
let qfl = []

" only one tag name
if (len(tags) == 1)
    silent execute 'silent! tag '.a:query.'|normal! zz'
    return
" no tags
elseif (len(tags) == 0)
    echohl WarningMsg
    echo 'Tags Not Found.'
    echohl None
    return
endif

" multiple tag names
for tag in tags
    let filename = tag['filename']
    let pattern  = tag['cmd']
    let des      = filename . '|' . pattern

    call add(qfl, des)
endfor

call fzf#run({'source': qfl, 'sink': function('s:tagsink'), 'down': '~20%'})

endfunction

function! s:tagsink(tag)
let tmp = split(a:tag, '|')
let file = tmp[0]
" 关闭 pattern magic, 防止函数有特殊字符没法匹配,例如:* . 这些字符
let cmd = '/\M'.tmp[1][1:]
echom cmd

execute 'silent! e '.file.'|set ws|silent! '.cmd.'|normal! zz'

endfunction

" command! -bang -nargs=* Ag call fzf#vim#ag(, '--ignore tags', {'options': '--delimiter : --nth 4..'}, 0)
command! -bang -nargs=* Ag call fzf#vim#ag_raw(, 0)
"
" ============= 自定义命令配置 END =============
"
"
"
" ============= 插件配置 START =============
"
" fzf
set rtp+=~/.fzf
let g:fzf_layout = { 'down': '~20%' }

nnoremap a :Ag -w
nnoremap h :History
nnoremap :Files
nnoremap :Buffers

" NERDTree
let g:NERDTreeQuitOnOpen = 1
let NERDTreeShowLineNumbers = 1
noremap :NERDTreeToggle

" tagbar
let g:tagbar_left = 1
let g:tagbar_autoclose = 1
let g:tagbar_show_linenumbers = 2
let g:tagbar_sort = 0

let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }

noremap t :TagbarToggle
noremap f :BTags

" Python-syntax
let python_highlight_all = 1
syntax enable " 打开语法高亮
syntax on " 开启文件类型侦测

" indentLine
let g:indentLine_enabled = 0 " 默认关闭

" go
let g:go_fmt_command = "goimports"
" let g:go_fmt_fail_silently = 1
" let g:go_fmt_autosave = 0 " 关闭自动格式化代码

let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_function_parameters = 1

let g:go_def_mapping_enabled = 0
let g:go_def_mode = 'gopls'

au FileType go noremap gd :GoDef
au FileType go inoremap 3b:GoImport zz3ea
au FileType go cnoremap GG GoImport

" YCM
set completeopt=longest,menu
let g:ycm_collect_identifiers_from_tags_files=1
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_filetype_blacklist = {
\ 'tagbar' : 1,
\ 'nerdtree' : 1,
}
let g:ycm_auto_trigger = 0
let g:ycm_show_diagnostics_ui = 0
let g:ycm_key_invoke_completion = ''
"let g:ycm_collect_identifiers_from_comments_and_strings = 1

" UltiSnips
let g:UltiSnipsExpandTrigger=""
let g:UltiSnipsJumpForwardTrigger=""
let g:UltiSnipsJumpBackwardTrigger=""
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/mysnippets']
"
" ============= 插件配置 END =============
"
"
"
" ============= 自定义配置 START =============
"
" 字典补全
set dictionary+=$HOME/.vim/doc/dict.txt
set complete+=k

" PHP 函数补全
function! s:AddPHPFuncListCodcodog()
set dictionary-=$HOME/.vim/doc/php.txt dictionary+=$HOME/.vim/doc/php.txt
set complete-=k complete+=k
endfunction

" go 补全
function! s:GoCompletionCodcodog()
set dictionary-=$HOME/.vim/doc/go.txt dictionary+=$HOME/.vim/doc/go.txt
set complete-=k complete+=k
endfunction

" python 补全
function! s:PythonCompletionCodcodog()
set dictionary-=$HOME/.vim/doc/python.txt dictionary+=$HOME/.vim/doc/python.txt
set complete-=k complete+=k
endfunction

" 保留当前可见 buffer, wipe out 其他不可见 buffers
function! s:OnlyCurrentBufferCodcodog()
" list of all buffer numbers
let l:buffers = range(1, bufnr('$'))

" what tab page are we in?
let l:currentTab = tabpagenr()
try
    " go through all tab pages
    let l:tab = 0
    while l:tab < tabpagenr('$')
        let l:tab += 1

        " go through all windows
        let l:win = 0
        while l:win < winnr('$')
            let l:win += 1
            " whatever buffer is in this window in this tab, remove it from
            " l:buffers list
            let l:thisbuf = winbufnr(l:win)
            call remove(l:buffers, index(l:buffers, l:thisbuf))
        endwhile
    endwhile

    " if there are any buffers left, delete them
    if len(l:buffers)
        execute 'bwipeout' join(l:buffers)
    endif
finally
    " go back to our original tab page
    execute 'tabnext' l:currentTab
endtry

endfunction

" PHP 文件,启用补全
augroup filetype_php
autocmd!
autocmd FileType php call AddPHPFuncListCodcodog()
augroup END

augroup filetype_go
autocmd!
autocmd FileType go call GoCompletionCodcodog()
augroup END

" Shell 文件,缩进修改为2个空格
augroup filetype_sh
autocmd!
autocmd FileType sh,yaml
\ set tabstop=2 |
\ set shiftwidth=2
augroup END

" python 文件,可视化缩进
" 加载补全
augroup filetype_python
autocmd!
" indentLine 插件配置
autocmd FileType python
\ let g:indentLine_enabled=1 |
\ let g:indentLine_char='·'
autocmd FileType python call PythonCompletionCodcodog()
augroup END
"
" ============= 自定义配置 START =============

Vim version (first three lines from :version):

VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov 7 2019 22:30:47)
Included patches: 1-2268
Compiled by Arch Linux

Go version (go version):

go version go1.13.5 linux/amd64

Go environment

go env Output:
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/cryven/.cache/go-build"
GOENV="/home/cryven/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/cryven/coding/azoya_product_query"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,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="/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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build309583313=/tmp/go-build -gno-record-gcc-switches"

vim-go configuration:

vim-go configuration
g:go_loaded_gosnippets = 1
g:go_highlight_function_calls = 1
g:go_highlight_fields = 1
g:go_def_mode = 'gopls'
g:go_highlight_function_parameters = 1
g:go_highlight_functions = 1
g:go_highlight_types = 1
g:go_fmt_command = 'goimports'
g:go_jump_to_error = 1
g:go_loaded_install = 1
g:go_def_mapping_enabled = 0

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