YouCompleteMe Golang-gopls不生效解决办法

最新版YouCompleMe中如果安装golang 有可能不生效

vim配置

" YouCompleteMe 配置
let g:ycm_server_python_interpreter='/usr/local/bin/python3'
" Note that you can install YCM with both libclang and clangd enabled. In that case clangd will be preferred unless you have the following in your vimrc:
"let g:ycm_use_clangd = 0
" 寻找全局配置文件
let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py"
let g:ycm_language_server =
  \ [
  \   {
  \     'name': 'gopls',
  \     'cmdline': [ '~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x/tools/cmd/gopls/gopls' , "-rpc.trace" ],
  \     'filetypes': [ 'go' ],
  \     "project_root_files": [ "go.mod" ]
  \   }
  \ ]

let g:go_def_mode='~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x/tools/cmd/gopls/gopls'
let g:go_info_mode='~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x/tools/cmd/gopls/gopls'
" 开启YouCompleteMe 日志模式
" let g:ycm_log_level = 'debug'
set completeopt=longest,menu

问题参考地址:

https://github.com/ycm-core/YouCompleteMe/issues/3465

解决方案:

cd ~/.vim/bundle/YouCompleteMe/third_party/ycmd
cd third_party/go/src/golang.org/x/tools
git pull origin master
cd cmd/gopls
// 需要注意, 编译的时候, 可能需要代理 , 否则无法编译成功
go build 
mv main gopls 

你可能感兴趣的:(YouCompleteMe Golang-gopls不生效解决办法)