Vim-go: Support Go modules

Created on 6 Aug 2018  ·  15Comments  ·  Source: fatih/vim-go

To support Go 1.11 fully, vim-go changes need to be made to handle module mode development.

  • [x] support for go.mod
  • [x] autocompletion (see https://github.com/fatih/vim-go/pull/1853#issuecomment-410776425)
  • [x] :GoImport tab completion (https://github.com/fatih/vim-go/issues/2212)
  • [ ] others....

Obviously, vim-go will be dependent on a number of tools getting updated to complete the support, but there are a number of changes that will need to be made to vim-go itself.

feature improvement

Most helpful comment

vim-go has good support from modules now. I'm closing this; any remaining gaps should be filed as separate issues.

All 15 comments

+1

But I think this plugin is hard to support the Go modules, at least not until https://github.com/golang/go/issues/24661 is fixed.

At minimum things like syntax highlighting can be added for the go.mod and go.sum files.

Added initial support for :GoModFmt (auto format the go.mod file) and syntax highlighting here: https://github.com/fatih/vim-go/pull/1931

Is it expected that things like auto fmt (and go imports) on save doesn't work outside of GOPATH?

@rkuska no, gofmt works on a single file and should work outside GOPATH.

Sorry for the noise, I had let g:go_fmt_fail_silently = 1 and there was syntax error in my file 🤦‍♂️ but when I cd-ed to my original GOPATH location the syntax error wasn't there and go fmt was working so I assumed the above.

:GoDoc also doesn't seem to work with modules.

:GoDoc also doesn't seem to work with modules.

It's not because of modules, it's just Go 1.11 removed this functionality from godoc. Looks like we should use go doc instead, but it show less information when viewing doc about whole package and thus require request per each single function/method, which means we need very good navigation to make it fast and easier to move between these small chunks of doc. Also I didn't found a way to move from doc to source with go doc. Maybe distributing old godoc binary with vim-go will solve these issues, but it's unclear if old godoc is compatible with modules (unlikely).

Some related discussion in PR #1988, including https://github.com/fatih/vim-go/pull/1988#issuecomment-424587539 and https://github.com/fatih/vim-go/pull/1988#issuecomment-428576989

Also some discussion in #2137, including:

I just found the hint that GoUpdateBinaries might could help and it works now for me.

it looks like there are some issues with the current go.mod syntax highlighting processing pre-release identifiers, want me to fork off a new issue:
2019-03-21-082142_376x134_scrot

vim-go has good support from modules now. I'm closing this; any remaining gaps should be filed as separate issues.

@bhcleek This is great!

Is there a thought around publishing a new official release? Most recent official release was November, I think.

And... looks like I should have waited slightly longer prior to asking about a new release... ;-)

https://github.com/fatih/vim-go/releases/tag/v1.20

Hi Folks, How can I make vim-go based code completion in a go-module use vendor folder in that module? Any pointers on how to set it up correctly is appreciated.

Also I hit following error for a project (it is a large project/module with over 100MB of source in multiple packages). Code completion and navigation works as expected for other smaller projects. Is this setting configurable?
source languageserver.golang timeout after 2000ms

Sorry to ask in a closed issue but my GoBuild isn't using the GO111MODULE=on. Is there something else I need to do to build with module?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mnarrell picture mnarrell  ·  3Comments

groob picture groob  ·  3Comments

preslavmihaylov picture preslavmihaylov  ·  3Comments

wpaulino picture wpaulino  ·  4Comments

jongillham picture jongillham  ·  3Comments