Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetInfo() echoes its result instead of a string return #1904

Closed
illotum opened this issue Aug 1, 2018 · 5 comments
Closed

GetInfo() echoes its result instead of a string return #1904

illotum opened this issue Aug 1, 2018 · 5 comments

Comments

@illotum
Copy link

illotum commented Aug 1, 2018

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

Assigned go#complete#GetInfo() to a variable.

What did you expect to happen?

String variable and no echo.

What happened instead?

GetInfo end up calling s:info_complete and the result is echoed.

This must be a fairly recent regression, I used this exact setup about a year ago successfully.

Configuration (MUST fill this out):

NVIM v0.3.1
Build type: Release
LuaJIT 2.0.5
  • Go version (go version):
go version go1.10.3 darwin/amd64
  • Go environment (go env):
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/alexv/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/alexv"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.3/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/yr/m790wsnd4h7gv5hknqhb7yq4
0000gn/T/go-build219756745=/tmp/go-build -gno-record-gcc-switches -fno-common"
@bhcleek
Copy link
Collaborator

bhcleek commented Aug 1, 2018

@illotum can you give #1905 a try?

@illotum
Copy link
Author

illotum commented Aug 2, 2018

@bhcleek Your branch returns 0 and still echoes the contents. If I comment out LL224-226 the echo part is gone, but the return is printed out as 0 anyways.

To clarify, according to docs GetInfo() is supposed to return description without any side effects:

Returns the description of the identifer under the cursor. Can be used to plug into the statusline.

@bhcleek
Copy link
Collaborator

bhcleek commented Aug 2, 2018

Thanks for teseting @illotum . I amended the PR. Can you try again?

bhcleek added a commit to bhcleek/vim-go that referenced this issue Aug 2, 2018
@illotum
Copy link
Author

illotum commented Aug 2, 2018

This one works, thank you!

If I may piggyback, related question:

For some reason, status is being properly filled through this exists call, but info is only printed out if I assign it directly (commented out), otherwise it stays set to "L". Are these two functions defined differently?

        function! GoStatus()
            let l:status = exists('*go#statusline#Show') ? go#statusline#Show() : 'S'
            let l:info = exists('*go#complete#GetInfo') ? go#complete#GetInfo() : 'L'
            " let l:info = go#complete#GetInfo()
            return printf('%s %s', l:status, l:info)
        endfunction

@bhcleek
Copy link
Collaborator

bhcleek commented Aug 3, 2018

It's probably because at the time exists(*go#complete#GetInfo) executes, the autoload/go/complete file hasn't been loaded, because nothing else has referenced a function in it yet, so exists returns false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants