Git Product home page Git Product logo

vim-go's Introduction

vim-go GitHub Actions Status

Vim-go logo

Features

This plugin adds Go language support for Vim, with the following main features:

  • Compile your package with :GoBuild, install it with :GoInstall or test it with :GoTest. Run a single test with :GoTestFunc).
  • Quickly execute your current file(s) with :GoRun.
  • Improved syntax highlighting and folding.
  • Debug programs with integrated delve support with :GoDebugStart.
  • Completion and many other features support via gopls.
  • formatting on save keeps the cursor position and undo history.
  • Go to symbol/declaration with :GoDef.
  • Look up documentation with :GoDoc or :GoDocBrowser.
  • Easily import packages via :GoImport, remove them via :GoDrop.
  • Precise type-safe renaming of identifiers with :GoRename.
  • See which code is covered by tests with :GoCoverage.
  • Add or remove tags on struct fields with :GoAddTags and :GoRemoveTags.
  • Lint your code with :GoLint or :GoMetaLinter, run your code through :GoVet to catch static errors, or make sure errors are checked with :GoErrCheck.
  • Advanced source analysis utilizing gopls, such as :GoImplements, :GoCallees, and :GoReferrers.
  • ... and many more! Please see doc/vim-go.txt for more information.
  • Integration with gopls.
  • The gopls instance can be shared with other Vim plugins.
  • Vim-go's use of gopls can be disabled and alternative tools can be used when desired.
  • Integration with Tagbar via gotags.
  • Integration with Ultisnips and other snippet engines.

Install

vim-go requires at least Vim 8.1.2269 or Neovim 0.4.0.

The latest stable release is the recommended version to use. If you choose to use the master branch instead, please do so with caution; it is a development branch.

vim-go follows the standard runtime path structure. Below are some helper lines for popular package managers:

  • Vim 8 packages
    • git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
  • Neovim packages
    • git clone https://github.com/fatih/vim-go.git ~/.local/share/nvim/site/pack/plugins/start/vim-go
  • Pathogen
    • git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go
  • vim-plug
    • Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
  • Vundle
    • Plugin 'fatih/vim-go'

You will also need to install all the necessary binaries. vim-go makes it easy to install all of them by providing a command, :GoInstallBinaries, which will go install all the required binaries.

Check out the Install section in the documentation for more detailed instructions (:help go-install).

Usage

The full documentation can be found at doc/vim-go.txt. You can display it from within Vim with :help vim-go.

Depending on your installation method, you may have to generate the plugin's help tags manually (e.g. :helptags ALL).

We also have a tutorial in the official vim-go wiki.

FAQ and troubleshooting

The FAQ and troubleshooting tips are in the documentation and can be quickly accessed using :help go-troubleshooting. If you believe you've found a bug or shortcoming in vim-go that is neither addressed by help nor in existing issues, please open an issue with clear reproduction steps. :GoReportGitHubIssue can be used pre-populate a lot of the information needed when creating a new issue.

Contributing

All PRs are welcome. If you are planning to contribute a large patch or to integrate a new tool, please create an issue first to get any upfront questions or design decisions out of the way first.

You can run the tests locally by running make. It will lint the VimL for you, lint the documentation, and run the tests against the minimum required version of Vim, other versions of Vim that may be critical to support, and Neovim.

License

The BSD 3-Clause License - see LICENSE for more details

vim-go's People

Contributors

abhinav avatar alexaandru avatar alexlafroscia avatar amirtcho avatar andrewstuart avatar arp242 avatar bhcleek avatar cespare avatar delphinus avatar dhduvall avatar eliasgs avatar fatih avatar felixoid avatar guns avatar hiberabyss avatar hori-ryota avatar igrmk avatar k33nice avatar lucapette avatar mattn avatar mmlb avatar mocheryl avatar nhooyr avatar nowk avatar pborzenkov avatar rbisewski avatar rhysd avatar riobard avatar variadico avatar yyoshiki41 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-go's Issues

Cannot autocomplete on assigment

i really like your vim plugin but i ran into an issue,

package main

import (
    "net"
)

func main() {
    l, err := net.Li // <-- hit CTRL + x CTRL + o
}

autocompletion works fine if the net.Li is on a single line alone, but with l, err := preceding it does not work for me, am i doing something wrong?

GoDoc opens browser

This is very much just a feature request.
I'd be interested in a feature in which GoDoc opens a browser window to show the documentation.

installer doesn't report GOPATH issue

Loving vim-go! I noticed another installer issue. If GOPATH isn't set correctly the installer fails. It would be great if you surfaced this issue to the user while installing too.
Thanks.

GoDoc not working with nested packages

GoDoc on e.g. io.EOF works, but not on ioutil.TempDir
GoDef works on both though
2014/04/04 02:46:28 open /usr/local/Cellar/go/1.2.1/libexec/src/pkg/ioutil: no such file or directory

Wrong stat

Whenever I execute GoRun I get the following error:

stat $/home/pjvds/go/src/github.com/pjvds/foobar/main.go: no such file or directory

Where is that $ sign coming from?

E154: Duplicate tag ":GoFmt" in file github-fatih-vim-go/doc/vim-go.txt

I'm getting the error E154: Duplicate tag ":GoFmt" in file github-fatih-vim-go/doc/vim-go.txt when installing/updating the plugin, this happens on generating help tags, and this should be happening because ":GoFmt" is not being escaped I think... when it's being referred as text inside vim-go.txt.

Warn when mercurial isn't installed

When starting vim-go for the first time, the downloader accesses 4 repos which appear to use mercurial. This may not be installed by default, it would be great if you could warn the user about this. I had to try and go get the packages by hand to figure out why it was failing. Many Thanks.

Fix :make and :GoBuild

:make should not source GoFiles at startup and :GoBuild shouldn't produce any binary. Basically they should be inversed.

Removes imports on :w.

On :w it removes all lines enclosed in import. It was working fine before, but now it doesn't.
(Thanks for making this plugin, by the way, it's very useful. :))

GoErrCheck only opens a new window the first time it is run

When running :GoErrCheck, the first time it is run a new window is opened listing the errors found. Running it subsequent times, though, no window opens listing the errors.

Note: it's quite possible that I have something misconfigured as I just began using vim-go. Overall it's a great tool and more than replaces the extensive go vim config I was previously using. Thanks for creating it.

Error when running Fmt:

I'm incredibly impressed with the plugin, looking to switch to this full time for my Go development!

Have come across one issue, but I'm having a bit of trouble getting some troubleshooting information about it. Running Fmt is returning an error, but I can't seem to figure out what that error or the return code of goimports is.

My test file:

package test

import (
    "fmt"
)

func main() {
    fmt.Println("This is a test.")
}

When running Fmt:

:Fmt
  1 package test
  2
  3 import (
  4     "fmt"
  5 )
  6
  7 func main() {
  8     fmt.Println("This is a test.")
  9 }
Gofmt returned error

My Go version:

➜  .vim-go  go version
go version go1.2 linux/amd64

Checking to see what the Fmt command delegates to:

:Let g:co_fmt_command
g:go_fmt_command       goimports

Running goimports manually seems to work:

➜  .vim-go  ~/.vim-go/goimports $GOPATH/src/test.go 
package test

import (
    "fmt"
)

func main() {
    fmt.Println("This is a test.")
}
➜  .vim-go  echo $?
0

I'm happy to keep debugging here locally as I'm assuming this will be very tricky to reproduce. Do you have any advice as to where I would start looking to get some more valuable debugging information?

Add g:go_fmt_failsilently option

:GoFmt or auto go fmt does shows the errors of the gofmt (or goimports) command. This option is going to try to save the file, but will prevent showing, and therefore populating the quickfix window.

gofmt integration is not working

I was using :Fmt without problems before trying to adopt vim-go, I have then removed all previous integration and switched to vim-go but now, when I try to save a go source file, I get a screen with all the buffer contents non-highlighted, I must scroll down to the bottom of this message (yes, the buffer contents is being output as an output message), at the bottom it says I must press any key to have the file saved. Also, in the end, no formatting is being applyed, both with the command, nor when it's being saved. I'm on Ubuntu 13.10 with a quite recent Vim build, 7.4.211.

Check a trailing path slash

let g:go_bin_path = expand("$GOPATH/bin")(without a trailing slash) would cause auto-installing on every restart.

error detected while processing function GoFiles

Just installed vim-go (on windows) and getting errors when opening .go files:

E484: Can't open file <path>\AppData\Local\Temp\VIo5EB7.tmp

.vim-go dir has: errcheck, golint, oracle, godef, goimports, gocode and installation didn't have any errors.

:GoFmt on :w mess with Vim :redo

I thought this plugin has settled this issue but sadly, it didn't. I was one of those who tried to provide a solution to a related question on SO. Still my approach, which I guess is the same being used here, will mess with redo. This is very simple to reproduce:

  • Open a Go source file.
  • Make some modification.
  • :w to save it.
  • Press u to undo the previous change.
  • :w to save it again, now with the original content.
  • Try press ctrl-r to redo the previous modification, it won't redo, but it should.

Playing with undo and redo, the cursor may go to the top of the file without one asking for, it's very annoying.

Error installing goimports, oracle and errcheck

When installing the three packages listed in the title do not install. None of them give an error message:

Installing code.google.com/p/go.tools/cmd/goimports Error installing code.google.com/p/go.tools/cmd/goimports: Installing code.google.com/p/go.tools/cmd/oracle Error installing code.google.com/p/go.tools/cmd/oracle: Installing github.com/kisielk/errcheck Error installing github.com/kisielk/errcheck: Press ENTER or type command to continue

Support for `go vet`

GoVet has some useful features. It would be nice if you had a command to call and populate the quickfix window like :GoErrCheck

gosnippet.vim breaks supertab

Hi,
I noticed that the snippet discovery in gosnippet.vim breaks supertab since it overwrites all <tab> settings. I discovered this when running :verbose imap <tab> and verified it by removing gosnippet.vim (which gives me back the expected behaviour).

nicer build visualization

before this plugin for build i was using Gobu https://github.com/Kashomon/gobu (actually i'm still using it overwriting some of your commands) it's quite a simple plugin, but it has much nicer visualization of errors without losing sight of your code

can something like this merged in?

Don't disable GoUpdateBinaries with g:go_disable_autoinstall = 1

I use vim for all of my text editing tasks. I like the fact that vim-go would fetch all necessary binaries for me, but on the other hand, every time I edit a file different than go, I get this:

vim.go: $GOPATH is not set
vim.go: you can disable auto install with 'let g:go_disable_autoinstall = 1'
Press ENTER or type command to continue

I can of course disable autoinstall, and do away with the message - but I'd still like to be able to use :GoUpdateBinaries by hand. Can you please change it so the command is not disabled? This way I can get uninterrupted vim startup and possibility to quickly install stuff by hand if it's missing.

Or perhaps just do away with the warning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.