ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.43k stars 2.81k forks source link

Update gopls installed by the go-completer #4197

Closed dhharris closed 9 months ago

dhharris commented 11 months ago

Issue Prelude

I'm getting the following error when opening a go file that uses the new module versioning

go.mod:3: invalid go version '1.21.3': must match format 1.23

This seems to be causing a lot of trouble with various software projects - after some discussions on the Gitter, I believe we need to update the verison of gopls to be compatible with these new versioning formats.

Workaround

Update gopls version using the cli

go install golang.org/x/tools/gopls@latest

Modify .vimrc to point to the new version

let g:ycm_gopls_binary_path = expand('$GOPATH/bin/gopls')

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

Thank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.

Issue Details

Include steps to reproduce here.

  1. vim -Nu ~/.bundle/YouCompleteMe/vimrc_ycm_minimal
  2. :e test.go
  3. Observe error loading packages

Include description of a minimal test case, including any actual code required to reproduce the issue.

Set up a new go module with some dependencies as a pre-requisite for reproducing the issue

$ mkdir ycm_test && cd ycm_test
$ cat >test.go << EOF
> package test
>
> import (
>     "github.com/stretchr/testify/require"
> )
> EOF

$ go mod init ycm_test
go: creating new go.mod: module ycm_test
go: to add module requirements and sums:
        go mod tidy
$ go get -u
go: added github.com/davecgh/go-spew v1.1.1
go: added github.com/pmezard/go-difflib v1.0.0
go: added github.com/stretchr/testify v1.8.4
go: added gopkg.in/yaml.v3 v3.0.1
$ cat go.mod
module ycm_test

go 1.21.3

require github.com/stretchr/testify v1.8.4

require (
        github.com/davecgh/go-spew v1.1.1 // indirect
        github.com/pmezard/go-difflib v1.0.0 // indirect
        gopkg.in/yaml.v3 v3.0.1 // indirect
)

I expected the packages to load and go completion to work correctly

Received an error due to malformed go version in go.mod

Diagnostic data

Output of vim --version

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Oct 07 2023 20:03:18)
macOS version - arm64
Included patches: 1-2000
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby              +wildignore
+cursorbind        +lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             +sound             -xattr
-dnd               -mouseshape        +spell             -xfontset
-ebcdic            +mouse_dec         +startuptime       -xim
+emacs_tags        -mouse_gpm         +statusline        -xpm
+eval              -mouse_jsbterm     -sun_workshop      -xsmp
+ex_extra          +mouse_netterm     +syntax            -xterm_clipboard
+extra_search      +mouse_sgr         +tag_binary        -xterm_save
-farsi             -mouse_sysmouse    -tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/opt/homebrew/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: clang -o vim -lm -lncurses -lsodium -liconv -lintl -framework AppKit -L/opt/homebrew/opt/lua/lib -llua5.4 -mmacosx-version-min=14.0 -fstack-protector-strong -L/opt/homebrew/opt/perl/lib/perl5/5.38/darwin-thread-multi-2level/CORE -lperl -L/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/config-3.11-darwin -lpython3.11 -framework CoreFoundation -lruby.3.2 -L/opt/homebrew/Cellar/ruby/3.2.2_1/lib 

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Resolve completions: Up front
-- Client logfile: /var/folders/tm/dpc775t148v9n9cjlvr3vby80000gn/T/ycm_tu5abj6r.log
-- Server Python interpreter: /opt/homebrew/opt/python@3.11/bin/python3.11
-- Server Python version: 3.11.6
-- Server has Clang support compiled in: False
-- Clang version: None
-- No extra configuration file found
-- Go completer debug information:
--   gopls running
--   gopls process ID: 35423
--   gopls executable: ['/Users/dhh/.bundle/YouCompleteMe/third_party/ycmd/third_party/go/bin/gopls', '-logfile', '/var/folders/tm/dpc775t148v9n9cjlvr3vby80000gn/T/gopls_stderr6p3y7lbu.log', '-rpc.trace']
--   gopls logfiles:
--     /var/folders/tm/dpc775t148v9n9cjlvr3vby80000gn/T/gopls_stderr6p3y7lbu.log
--   gopls Server State: Initialized
--   gopls Project Directory: /Users/dhh/ycm_test
--   gopls Settings: {
--   "hints": {
--     "assignVariableTypes": true,
--     "compositeLiteralFields": true,
--     "compositeLiteralTypes": true,
--     "constantValues": true,
--     "functionTypeParameters": true,
--     "parameterNames": true,
--     "rangeVariableTypes": true
--   },
--   "hoverKind": "Structured",
--   "semanticTokens": true
-- }
-- Server running at: http://127.0.0.1:61297
-- Server process ID: 35422
-- Server logfiles:
--   /var/folders/tm/dpc775t148v9n9cjlvr3vby80000gn/T/ycmd_61297_stdout_f5jq3757.log
--   /var/folders/tm/dpc775t148v9n9cjlvr3vby80000gn/T/ycmd_61297_stderr_brp9qglu.log
-- Semantic highlighting supported: True
-- Virtual text supported: True
-- Popup windows supported: True

Output of YcmDiags

No warnings or errors detected.

Output of git rev-parse HEAD in YouCompleteMe installation directory

$ git -C ~/.bundle/YouCompleteMe rev-parse HEAD
cc9a3ae3efdcc7d038aab0620ea28882533c236c

Contents of YCM, ycmd and completion engine logfiles

Reproduce the issue with vim -Nu /path/to/YCM/vimrc_ycm_minimal, which enabled debug logging and other useful diagnostics. Include a link to a gist containing all of the log files listed by :YcmToggleLogs.

https://gist.github.com/dhharris/3df11077da7771a80b67d62ae6f7a823

OS version, distribution, etc.

Software:

    System Software Overview:

      System Version: macOS 14.0 (23A344)
      Kernel Version: Darwin 23.0.0
bstaletic commented 9 months ago

We have updated gopls/ycmd today. Just update YCM and submodules.