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

Help with gopls #664

Closed
lanox opened this issue Apr 7, 2019 · 26 comments
Closed

Help with gopls #664

lanox opened this issue Apr 7, 2019 · 26 comments
Labels
help wanted Extra attention is needed

Comments

@lanox
Copy link

lanox commented Apr 7, 2019

Hi

I am not sure if this is a issue or maybe just me not knowing how to configure it, I am using go1.12.1 darwin/amd64.

I am trying to configure gopls in coc-settings.json

    "golang": {
      "command": "gopls",
      "rootPatterns": ["go.mod", ".vim/", ".git/", ".hg/"],
      "filetypes": ["go"]
    }

I have also install gopls as per this instructions, https://github.com/golang/go/wiki/gopls
go get -u golang.org/x/tools/cmd/gopls

however autocompletion is not working, If i change it to go-langserver it's working fine.

if you could assist would be greatly appreciated.

@lanox lanox changed the title Not sure if this is bug or just me Help with gopls Apr 7, 2019
@chemzqm chemzqm added the help wanted Extra attention is needed label Apr 8, 2019
@chemzqm
Copy link
Member

chemzqm commented Apr 8, 2019

It looks like you need to pass extra arguments to the command, but I'm not sure.

@lanox
Copy link
Author

lanox commented Apr 8, 2019

2019/04/08 13:23:57 get package failed: no packages found for /Users/xx/code/go/src/github.com/lanox/lanox.go
2019/04/08 13:23:58 get token failed: no packages found for /Users/xx/code/go/src/github.com/lanox/lanox.go

adding under gopls in coc-settings.json "args": ["-logfile=lano.log"], I get above error messages

@glepnir
Copy link
Contributor

glepnir commented Apr 8, 2019

@lanox try this

git clone -b bingo https://github.com/saibing/tools.git
cd tools/cmd/gopls
go install

@lanox
Copy link
Author

lanox commented Apr 8, 2019

@taigacute tried that as well, no luck, that was the first thing I did.

After digging more through it, it seems that only works if you are in your GOPATH.
e.g
if I am in my $HOME, and I do vi lanox.go autocompletion will not work.

If I am navigate to my $GOPATH and do same as above, autocompletion works, although I don't get any documentation on floating window like I do with go-langserver.

@glepnir
Copy link
Contributor

glepnir commented Apr 8, 2019

@lanox it surpport go mod project you should go mod init

@glepnir
Copy link
Contributor

glepnir commented Apr 8, 2019

I don't get any documentation on floating window like I do with go-langserver.

this is a question i said to @chemzqm . the dohover of gopls works well on vscode. but didnt work with coc

@chemzqm
Copy link
Member

chemzqm commented Apr 8, 2019

the dohover of gopls works well on vscode. but didnt work with coc

Need output of language server https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel

@lanox
Copy link
Author

lanox commented Apr 8, 2019

I am little confused with gopls, if I open my existing project it seems that autocompletion works, however if I start new project and start typing code, autocompletion will not work.

@glepnir
Copy link
Contributor

glepnir commented Apr 8, 2019

@lanox if your project is a go mod pro you should go mod init first,Known issue, unsaved buffer import third party package auto completion is not working, waiting to be repaired,Gopls are unstable and have many problems.

@lanox
Copy link
Author

lanox commented Apr 8, 2019

@taigacute that is the interesting part, it is not this is just a normal folder with a .go file in it.

@chemzqm
Copy link
Member

chemzqm commented Apr 8, 2019

It might requires a correct workspaceFolder to work ,check out https://github.com/neoclide/coc.nvim/wiki/Using-workspaceFolders

@lanox
Copy link
Author

lanox commented Apr 8, 2019

ah, I am giving up on gopls, its just pain, and random.

@alzedd
Copy link

alzedd commented Apr 8, 2019

    "languageserver": {
        "golang": {
            "command": "gopls",
            "filetypes": ["go"],
        }
    }

this is my settings for gopls.

  1. be sure to have $GOPATH correctly set
  2. use go-modules (You will get an error code 0 otherwise)
  3. the go file must exsist, you can't just open a new buffer (eg :e newfile.go)

EDIT: try using https://github.com/saibing/tools (it's just gopls with some edits the bingo developer did on the code)

@Cluas
Copy link

Cluas commented May 3, 2019

golang/go#29202

@lanox
Copy link
Author

lanox commented May 6, 2019

Has anyone had any luck setting up any of GO language servers. I cant seem to get auto completion working for gopls or go-langserver. Can someone please help me out, or help me troubleshoot it.

@glepnir
Copy link
Contributor

glepnir commented May 6, 2019

works well
11

@akinsho
Copy link

akinsho commented May 8, 2019

I managed to get it working with @alzedd's advice but it doesn't show any completion till you hit . so in my case for the screenshot above log wouldn't be in the autocompletion only log.F would give options

@glepnir
Copy link
Contributor

glepnir commented May 9, 2019

@Akin909 i use my config not @alzedd 's advice.

@lanox
Copy link
Author

lanox commented May 10, 2019

It seems to be working okay for me, however no floating windows, but I think that is due to gopls issue.

@taigacute to be honest with you screenshot you are showing only snippets, at least when I looked at you config you had stars if the definition is coming from snippets.

@lanox lanox closed this as completed May 10, 2019
@glepnir
Copy link
Contributor

glepnir commented May 10, 2019

@lanox not snippets. do you see the [ls] that mean the completion from server

@lanox
Copy link
Author

lanox commented May 10, 2019

Yep I agree, i did not see that, however I did see in your config that your snippets also have stars, so I just assumed. Never assume I guess.

@luan
Copy link

luan commented May 22, 2019

@lanox did you get it working with upstream gopls? It'd be great if coc.nvim didn't depend on the fork. Installing from the fork is a pain and it breaks all sorts of things with golang.org/x/tools

@lanox
Copy link
Author

lanox commented May 23, 2019

@luan no not really, its sporadic, but I haven't tried it in a while.

@ucef29
Copy link

ucef29 commented Dec 1, 2019

@lanox workAround: add the full path to your gopls in the cocConfig json... here:

{
  "languageserver": {
    "golang": {
      "command": "[full-path-to-your-gopls-binary]/gopls",
      "rootPatterns": ["go.mod", ".vim/", ".git/", ".hg/"],
      "filetypes": ["go"]
    }
  }
}

@luispe
Copy link

luispe commented Jul 26, 2020

Thanks @ucef29 your suggestion "command": "[full-path-to-your-gopls-binary]/gopls" it works for me.
Than you very much 💯

@oblitum
Copy link
Member

oblitum commented Jul 26, 2020

There's the coc-go extension too, which is even nicer and easier to use.

rjoost pushed a commit to rjoost/coc.nvim that referenced this issue Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

10 participants