2014-10-31 21:30:24 +00:00
|
|
|
|
*vim-go.txt* Go development plugin
|
|
|
|
|
*vim-go*
|
|
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
|
# #
|
|
|
|
|
# ## ## #### ## ## ###### ####### #
|
|
|
|
|
# ## ## ## ### ### ## ## ## ## #
|
|
|
|
|
# ## ## ## #### #### ## ## ## #
|
|
|
|
|
# ## ## ## ## ### ## ####### ## #### ## ## #
|
|
|
|
|
# ## ## ## ## ## ## ## ## ## #
|
|
|
|
|
# ## ## ## ## ## ## ## ## ## #
|
|
|
|
|
# ### #### ## ## ###### ####### #
|
|
|
|
|
# #
|
|
|
|
|
===============================================================================
|
|
|
|
|
CONTENTS *go-contents*
|
|
|
|
|
|
|
|
|
|
1. Intro........................................|go-intro|
|
|
|
|
|
2. Install......................................|go-install|
|
|
|
|
|
3. Commands.....................................|go-commands|
|
2015-01-18 12:58:28 +00:00
|
|
|
|
4. Mappings.....................................|go-mappings|
|
|
|
|
|
5. Text Objects.................................|go-text-objects|
|
|
|
|
|
6. Settings.....................................|go-settings|
|
|
|
|
|
7. Troubleshooting..............................|go-troubleshooting|
|
|
|
|
|
8. Credits......................................|go-credits|
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
|
INTRO *go-intro*
|
|
|
|
|
|
|
|
|
|
Go (golang) support for Vim. vim-go installs automatically all necessary
|
|
|
|
|
binaries for providing seamless Vim integration. It comes with pre-defined
|
|
|
|
|
sensible settings (like auto gofmt on save), has autocomplete, snippet
|
|
|
|
|
support, improved syntax highlighting, go toolchain commands, etc... It's
|
|
|
|
|
highly customizable and each individual feature can be disabled/enabled
|
|
|
|
|
easily.
|
|
|
|
|
|
|
|
|
|
* Improved Syntax highlighting, such as Functions, Operators, Methods..
|
|
|
|
|
* Auto completion support via `gocode`
|
|
|
|
|
* Better `gofmt` on save, keeps cursor position and doesn't break your undo
|
|
|
|
|
history
|
|
|
|
|
* Go to symbol/declaration with `godef`
|
2015-03-14 20:02:10 +00:00
|
|
|
|
* Look up documentation with `godoc` inside Vim or open it in browser.
|
2014-10-31 21:30:24 +00:00
|
|
|
|
* Automatically import packages via `goimports`
|
|
|
|
|
* Compile and `go build` your package, install it with `go install`
|
|
|
|
|
* `go run` quickly your current file/files
|
|
|
|
|
* Run `go test` and see any errors in quickfix window
|
2015-03-14 20:02:10 +00:00
|
|
|
|
* Create a coverage profile and display annotated source code in browser to
|
|
|
|
|
see which functions are covered.
|
2014-10-31 21:30:24 +00:00
|
|
|
|
* Lint your code with `golint`
|
|
|
|
|
* Run your code trough `go vet` to catch static errors.
|
|
|
|
|
* Advanced source analysis tool with `oracle`
|
|
|
|
|
* Precise type-safe renaming of identifiers with `gorename`
|
|
|
|
|
* List all source files and dependencies
|
|
|
|
|
* Checking with `errcheck` for unchecked errors.
|
|
|
|
|
* Integrated and improved snippets. Supports `ultisnips` or `neosnippet`
|
|
|
|
|
* Share your current code to play.golang.org
|
2015-03-14 20:02:10 +00:00
|
|
|
|
* On-the-fly type information about the word under the cursor
|
2014-10-31 21:30:24 +00:00
|
|
|
|
* Tagbar support to show tags of the source code in a sidebar with `gotags`
|
2015-03-14 20:02:10 +00:00
|
|
|
|
* Custom vim text objects, such a `a function` or `inner function`
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
|
INSTALL *go-install*
|
|
|
|
|
|
2015-03-14 20:02:10 +00:00
|
|
|
|
Vim-go follows the standard runtime path structure, so I highly recommend to use
|
|
|
|
|
a common and well known plugin manager to install vim-go. Do not use vim-go with
|
|
|
|
|
other Go plugins. For Pathogen just clone the repo, for other plugin managers
|
|
|
|
|
add the appropriate lines and execute the plugin's install command.
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
2015-03-14 20:02:10 +00:00
|
|
|
|
* https://github.com/tpope/vim-pathogen >
|
|
|
|
|
|
|
|
|
|
git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go
|
2014-10-31 21:30:24 +00:00
|
|
|
|
<
|
|
|
|
|
|
2015-03-14 20:02:10 +00:00
|
|
|
|
* https://github.com/junegunn/vim-plug >
|
|
|
|
|
|
|
|
|
|
Plug 'fatih/vim-go'
|
|
|
|
|
|
2014-10-31 21:30:24 +00:00
|
|
|
|
<
|
2015-03-14 20:02:10 +00:00
|
|
|
|
* https://github.com/Shougo/neobundle.vim >
|
|
|
|
|
|
|
|
|
|
NeoBundle 'fatih/vim-go'
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
* https://github.com/gmarik/vundle >
|
|
|
|
|
|
|
|
|
|
Plugin 'fatih/vim-go'
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
2015-03-14 20:02:10 +00:00
|
|
|
|
<
|
|
|
|
|
* Manual >
|
|
|
|
|
|
|
|
|
|
Copy all of the files into your `~/.vim` directory
|
|
|
|
|
<
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
2015-03-14 20:02:10 +00:00
|
|
|
|
Please be sure all necessary binaries are installed (such as `gocode`, `godef`,
|
2014-10-31 21:30:24 +00:00
|
|
|
|
`goimports`, etc..). You can easily install them with the included
|
2015-03-14 20:02:10 +00:00
|
|
|
|
|GoInstallBinaries| command. If you invoke it, all necessary binaries will be
|
|
|
|
|
automatically downloaded and installed to your `$GOBIN` environment (if not set
|
|
|
|
|
it will use `$GOPATH/bin`). It requires `git` for fetching the individual Go
|
|
|
|
|
packages.
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
|
|
|
|
* Autocompletion is enabled by default via `<C-x><C-o>`, to get real-time
|
|
|
|
|
completion (completion by type) install:
|
|
|
|
|
https://github.com/Valloric/YouCompleteMe or
|
|
|
|
|
https://github.com/Shougo/neocomplete.vim
|
|
|
|
|
* To get displayed source code tag informations on a sidebar install
|
|
|
|
|
https://github.com/majutsushi/tagbar.
|
|
|
|
|
* For snippet feature install:
|
|
|
|
|
https://github.com/SirVer/ultisnips or
|
|
|
|
|
https://github.com/Shougo/neosnippet.vim.
|
|
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
|
COMMANDS *go-commands*
|
|
|
|
|
|
|
|
|
|
*:GoImport*
|
|
|
|
|
:GoImport [path]
|
|
|
|
|
|
|
|
|
|
Import ensures that the provided package {path} is imported in the current
|
|
|
|
|
Go buffer, using proper style and ordering. If {path} is already being
|
|
|
|
|
imported, an error will be displayed and the buffer will be untouched.
|
|
|
|
|
|
|
|
|
|
*:GoImportAs*
|
|
|
|
|
:GoImportAs [localname] [path]
|
|
|
|
|
|
|
|
|
|
Same as Import, but uses a custom local name for the package.
|
|
|
|
|
|
|
|
|
|
*:GoDrop*
|
|
|
|
|
:GoDrop [path]
|
|
|
|
|
|
|
|
|
|
Remove the import line for the provided package {path}, if present in the
|
|
|
|
|
current Go buffer. If {path} is not being imported, an error will be
|
|
|
|
|
displayed and the buffer will be untouched.
|
|
|
|
|
|
|
|
|
|
*:GoLint*
|
|
|
|
|
:GoLint
|
|
|
|
|
|
|
|
|
|
Run golint for the current Go file.
|
|
|
|
|
|
|
|
|
|
*:GoDoc*
|
|
|
|
|
:GoDoc [word]
|
|
|
|
|
|
|
|
|
|
Open the relevant GoDoc in split window for either the word[s] passed to
|
|
|
|
|
the command or by default, the word under the cursor.
|
|
|
|
|
|
|
|
|
|
*:GoDocBrowser*
|
|
|
|
|
:GoDocBrowser [word]
|
|
|
|
|
|
|
|
|
|
Open the relevant GoDoc in browser for either the word[s] passed to the
|
|
|
|
|
command or by default, the word under the cursor.
|
|
|
|
|
|
|
|
|
|
*:GoFmt*
|
|
|
|
|
:GoFmt
|
|
|
|
|
|
|
|
|
|
Filter the current Go buffer through gofmt. It tries to preserve cursor
|
|
|
|
|
position and avoids replacing the buffer with stderr output.
|
|
|
|
|
|
|
|
|
|
*:GoImports*
|
|
|
|
|
:GoImports
|
|
|
|
|
|
|
|
|
|
Filter the current Go buffer through goimports (needs to be installed).
|
|
|
|
|
`goimports` automatically discards/add import path based on the code. Like
|
2015-01-18 12:58:28 +00:00
|
|
|
|
|GoFmt|, It tries to preserve cursor position and avoids replacing the
|
2014-10-31 21:30:24 +00:00
|
|
|
|
buffer with stderr output.
|
|
|
|
|
|
|
|
|
|
*:GoPlay*
|
|
|
|
|
:[range]GoPlay
|
|
|
|
|
|
|
|
|
|
Share snippet to play.golang.org. If no [range] is given it shares
|
|
|
|
|
the whole file, otherwise the selected lines are shared. Snippet URL
|
|
|
|
|
is copied to system clipboard if Vim is compiled with 'clipboard' or
|
|
|
|
|
'xterm-clipboard' otherwise it's get yanked into the `""` register.
|
|
|
|
|
|
|
|
|
|
*:GoVet*
|
|
|
|
|
:GoVet
|
|
|
|
|
|
|
|
|
|
Run `go vet` for the directory under your current file. Vet examines Go
|
|
|
|
|
source code and reports suspicious constructs, such as Printf calls whose
|
|
|
|
|
arguments do not align with the format string. Vet uses heuristics that do not
|
|
|
|
|
guarantee all reports are genuine problems, but it can find errors not caught
|
|
|
|
|
by the compilers.
|
|
|
|
|
|
|
|
|
|
*:GoDef*
|
|
|
|
|
:GoDef [identifier]
|
|
|
|
|
|
|
|
|
|
Goto declaration/definition for the given [identifier]. If no argument is
|
|
|
|
|
given, it will jump to the declaration under the cursor. By default the
|
2015-01-18 12:58:28 +00:00
|
|
|
|
mapping `gd` is enabled to invoke GoDef for the identifier under the cursor.
|
2014-10-31 21:30:24 +00:00
|
|
|
|
See |g:go_def_mapping_enabled| to disable it.
|
|
|
|
|
|
|
|
|
|
*:GoRun*
|
|
|
|
|
:GoRun[!] [expand]
|
|
|
|
|
|
|
|
|
|
Build and run your current main package. By default all main files for the
|
|
|
|
|
current file is used. If an argument is passed, 'expand' is used as file
|
2015-01-18 12:58:28 +00:00
|
|
|
|
selector. For example use `:GoRun %` to select the current file only.
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
|
|
|
|
If [!] is not given the first error is jumped to.
|
|
|
|
|
|
|
|
|
|
*:GoBuild*
|
2015-01-18 12:58:28 +00:00
|
|
|
|
:GoBuild[!] [options]
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
|
|
|
|
Build your package with `go build`. It automatically builds only the files
|
|
|
|
|
that depends on the current file. GoBuild doesn't produce a result file.
|
2015-01-18 12:58:28 +00:00
|
|
|
|
Use 'make' to create a result file.
|
|
|
|
|
|
|
|
|
|
You may optionally pass any valid go build flags/options. For a full list
|
|
|
|
|
please see `go help build`.
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
|
|
|
|
If [!] is not given the first error is jumped to.
|
|
|
|
|
|
|
|
|
|
*:GoInfo*
|
|
|
|
|
:GoInfo
|
|
|
|
|
Show type information about the identifer under the cursor. For example
|
|
|
|
|
putting it above a function call is going to show the full function
|
|
|
|
|
signature. It uses gocode to get the type informations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*:GoInstall*
|
|
|
|
|
:GoInstall
|
|
|
|
|
|
|
|
|
|
Install your package with `go install`.
|
|
|
|
|
|
|
|
|
|
*:GoTest*
|
|
|
|
|
:GoTest [expand]
|
|
|
|
|
|
2015-03-14 20:02:10 +00:00
|
|
|
|
Run the tests on your _test.go files via in your current directory. Errors
|
|
|
|
|
are populated in quickfix window. If an argument is passed, 'expand' is
|
|
|
|
|
used as file selector (useful for cases like `:GoTest ./...`).
|
|
|
|
|
|
|
|
|
|
*:GoTestCompile*
|
|
|
|
|
:GoTestCompile [expand]
|
|
|
|
|
|
|
|
|
|
Compile your _test.go files via in your current directory. Errors are
|
2014-10-31 21:30:24 +00:00
|
|
|
|
populated in quickfix window. If an argument is passed, 'expand' is used
|
2015-03-14 20:02:10 +00:00
|
|
|
|
as file selector (useful for cases like `:GoTest ./...`). Useful to not
|
|
|
|
|
run the tests and capture/fix errors before running the tests or to
|
|
|
|
|
create test binary.
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
|
|
|
|
*:GoCoverage*
|
|
|
|
|
:GoCoverage
|
|
|
|
|
|
|
|
|
|
Create a coverage profile and open a browser to display the annotated
|
|
|
|
|
source code of the current package.
|
|
|
|
|
|
|
|
|
|
*:GoErrCheck*
|
|
|
|
|
:GoErrCheck
|
|
|
|
|
|
|
|
|
|
Check for unchecked errors in you current package. Errors are populated in
|
|
|
|
|
quickfix window.
|
|
|
|
|
|
|
|
|
|
*:GoFiles*
|
|
|
|
|
:GoFiles
|
|
|
|
|
|
|
|
|
|
Show source files that depends for the current package
|
|
|
|
|
|
|
|
|
|
*:GoDeps*
|
|
|
|
|
:GoDeps
|
|
|
|
|
|
|
|
|
|
Show dependencies for the current package
|
|
|
|
|
|
|
|
|
|
*:GoInstallBinaries*
|
|
|
|
|
:GoInstallBinaries
|
|
|
|
|
|
|
|
|
|
Download and Install all necessary Go tool binaries such as `godef`,
|
|
|
|
|
`goimports`, `gocode`, etc.. under `g:go_bin_path`
|
|
|
|
|
|
|
|
|
|
*:GoUpdateBinaries*
|
|
|
|
|
:GoUpdateBinaries
|
|
|
|
|
|
|
|
|
|
Download and Update previously installed Go tool binaries such as `godef`,
|
|
|
|
|
`goimports`, `gocode`, etc.. under `g:go_bin_path`. This can be used to
|
|
|
|
|
update the necessary Go binaries.
|
|
|
|
|
|
|
|
|
|
*:GoImplements*
|
|
|
|
|
:GoImplements
|
|
|
|
|
|
|
|
|
|
Show 'implements' relation for a selected package. A list of interfaces
|
2015-01-18 12:58:28 +00:00
|
|
|
|
for the type that implements an interface under the cursor (or selected
|
2015-02-24 10:45:22 +00:00
|
|
|
|
package) is shown quickfix list.
|
2014-10-31 21:30:24 +00:00
|
|
|
|
*:GoRename*
|
|
|
|
|
:GoRename [to]
|
|
|
|
|
|
|
|
|
|
Rename the identifier under the cursor to the desired new name. If no
|
|
|
|
|
argument is given a prompt will ask for the desired identifier.
|
|
|
|
|
|
2015-01-18 12:58:28 +00:00
|
|
|
|
*:GoCallees*
|
|
|
|
|
:GoCallees
|
|
|
|
|
|
2015-02-24 10:45:22 +00:00
|
|
|
|
Show 'callees' relation for a selected package. A list of possible call
|
|
|
|
|
targets for the type under the cursor (or selected package) is shown in a
|
|
|
|
|
quickfix list.
|
|
|
|
|
|
|
|
|
|
*:GoCallers*
|
|
|
|
|
:GoCallers
|
|
|
|
|
|
|
|
|
|
Show 'callers' relation for a selected function. A list of possible
|
|
|
|
|
callers for the selected function under the cursor is shown in a quickfix
|
|
|
|
|
list.
|
|
|
|
|
|
|
|
|
|
*:GoDescribe*
|
|
|
|
|
:GoDescribe
|
|
|
|
|
|
|
|
|
|
Shows various properties of the selected syntax: its syntactic kind, its
|
|
|
|
|
type (for an expression), its value (for a constant expression), its size,
|
|
|
|
|
alignment, method set and interfaces (for a type), its declaration (for an
|
|
|
|
|
identifier), etc. Almost any piece of syntax may be described, and the
|
|
|
|
|
oracle will try to print all the useful information it can.
|
|
|
|
|
|
|
|
|
|
*:GoCallgraph*
|
|
|
|
|
:GoCallgraph
|
|
|
|
|
|
|
|
|
|
Shows the 'callgraph' for the entire program. For more info about the
|
|
|
|
|
indentation checkout the Oracle User Manual:
|
|
|
|
|
golang.org/s/oracle-user-manual
|
|
|
|
|
|
|
|
|
|
*:GoCallstack*
|
|
|
|
|
:GoCallstack
|
|
|
|
|
|
|
|
|
|
Shows 'callstack' relation for the selected function. An arbitrary path
|
|
|
|
|
from the root of the callgrap to the selected function is showed in a
|
|
|
|
|
quickfix list. This may be useful to understand how the function is
|
|
|
|
|
reached in a given program.
|
|
|
|
|
|
|
|
|
|
*:GoFreevars*
|
|
|
|
|
:GoFreevars
|
|
|
|
|
|
|
|
|
|
Enumerates the free variables of the selection. “Free variables” is a
|
|
|
|
|
technical term meaning the set of variables that are referenced but not
|
|
|
|
|
defined within the selection, or loosely speaking, its inputs.
|
|
|
|
|
|
|
|
|
|
This information is useful if you’re considering whether to refactor the
|
|
|
|
|
selection into a function of its own, as the free variables would be the
|
|
|
|
|
necessary parameters of that function. It’s also useful when you want to
|
|
|
|
|
understand what the inputs are to a complex block of code even if you
|
|
|
|
|
don’t plan to change it.
|
|
|
|
|
|
|
|
|
|
*:GoChannelPeers*
|
|
|
|
|
:GoChannelPeers
|
|
|
|
|
|
|
|
|
|
Shows the set of possible sends/receives on the channel operand of the
|
|
|
|
|
selected send or receive operation; the selection must be a <- token.
|
|
|
|
|
|
|
|
|
|
For example, visually select a channel operand in the form of:
|
|
|
|
|
|
|
|
|
|
"done <- true"
|
|
|
|
|
|
|
|
|
|
and call |GoChannelPeers| on it. It will show where it was allocated, and
|
|
|
|
|
the sending and receiving endings.
|
|
|
|
|
|
|
|
|
|
*:GoReferrers*
|
|
|
|
|
:GoReferrers
|
|
|
|
|
|
|
|
|
|
The referrers query shows the set of identifiers that refer to the same
|
|
|
|
|
object as does the selected identifier, within any package in the analysis
|
|
|
|
|
scope.
|
2015-01-18 12:58:28 +00:00
|
|
|
|
|
|
|
|
|
|
2014-10-31 21:30:24 +00:00
|
|
|
|
===============================================================================
|
|
|
|
|
MAPPINGS *go-mappings*
|
|
|
|
|
|
|
|
|
|
vim-go has several <Plug> keys which can be used to create custom mappings
|
|
|
|
|
For example, to create a mapping that `go run` the current file create a
|
|
|
|
|
mapping for the `(go-run)`: >
|
|
|
|
|
|
|
|
|
|
au FileType go nmap <leader>r <Plug>(go-run)
|
|
|
|
|
|
2015-02-24 10:45:22 +00:00
|
|
|
|
As always one is free to create more advanced mappings or functions based with
|
|
|
|
|
|go-commands|. For more information please check out the mappings command
|
|
|
|
|
documentation in the |go-commands| section. Available <Plug> keys are:
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
|
|
|
|
*(go-run)*
|
|
|
|
|
|
|
|
|
|
Calls `go run` for the current file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-build)*
|
|
|
|
|
|
|
|
|
|
Calls `go build` for the current package
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-info)*
|
|
|
|
|
|
|
|
|
|
Shows type information for the word under the cursor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-install)*
|
|
|
|
|
|
|
|
|
|
Calls `go install` for the current package
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-test)*
|
|
|
|
|
|
|
|
|
|
Calls `go test` for the current package
|
|
|
|
|
|
2015-03-14 20:02:10 +00:00
|
|
|
|
*(go-test-compile)*
|
|
|
|
|
|
|
|
|
|
Calls `go test -c` for the current package
|
|
|
|
|
|
2014-10-31 21:30:24 +00:00
|
|
|
|
*(go-coverage)*
|
|
|
|
|
|
|
|
|
|
Calls `go test -coverprofile-temp.out` for the current package
|
|
|
|
|
|
|
|
|
|
*(go-vet)*
|
|
|
|
|
|
|
|
|
|
Calls `go vet` for the current package
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-files)*
|
|
|
|
|
|
|
|
|
|
Show source files that depends for the current package
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-deps)*
|
|
|
|
|
|
|
|
|
|
Show dependencies for the current package
|
|
|
|
|
|
|
|
|
|
*(go-doc)*
|
|
|
|
|
|
|
|
|
|
Show the relevant GoDoc for the word under the cursor in a split window
|
|
|
|
|
leftabove (default mode).
|
|
|
|
|
|
|
|
|
|
*(go-doc-split)*
|
|
|
|
|
|
|
|
|
|
Show the relevant GoDoc for the word under the cursor in a split window.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-doc-vertical)*
|
|
|
|
|
|
|
|
|
|
Show the relevant GoDoc for the word under the cursor in a vertical split
|
|
|
|
|
window.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-doc-tab)*
|
|
|
|
|
|
|
|
|
|
Show the relevant GoDoc for the word under the cursor in a tab window.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-doc-browser)*
|
|
|
|
|
|
|
|
|
|
Show the relevant GoDoc for the word under in browser
|
|
|
|
|
|
|
|
|
|
*(go-def)*
|
|
|
|
|
|
|
|
|
|
Goto declaration/definition. Results are shown in the current buffer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-def-split)*
|
|
|
|
|
|
|
|
|
|
Goto declaration/definition. Results are shown in a split window.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-def-vertical)*
|
|
|
|
|
|
|
|
|
|
Goto declaration/definition. Results are shown in a vertical split window.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-def-tab)*
|
|
|
|
|
|
|
|
|
|
Goto declaration/definition. Results are shown in a tab window.
|
|
|
|
|
|
|
|
|
|
*(go-implements)*
|
|
|
|
|
|
|
|
|
|
Show the interfaces that the type under the cursor implements.
|
|
|
|
|
|
|
|
|
|
*(go-rename)*
|
|
|
|
|
|
|
|
|
|
Rename the identifier under the cursor to the desired new name
|
|
|
|
|
|
2015-01-18 12:58:28 +00:00
|
|
|
|
*(go-callees)*
|
|
|
|
|
|
|
|
|
|
Show the call targets for the type under the cursor
|
|
|
|
|
|
2015-02-24 10:45:22 +00:00
|
|
|
|
*(go-callers)*
|
|
|
|
|
|
|
|
|
|
Show possible callers of selected function
|
|
|
|
|
|
|
|
|
|
*(go-describe)*
|
|
|
|
|
|
|
|
|
|
Describe selected syntax: definition, methods, etc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(go-callgraph)*
|
|
|
|
|
|
|
|
|
|
Show the callgraph of the current program.
|
|
|
|
|
|
|
|
|
|
*(go-callstack)*
|
|
|
|
|
|
|
|
|
|
Show path from callgraph root to selected function
|
|
|
|
|
|
|
|
|
|
*(go-freevars)*
|
|
|
|
|
|
|
|
|
|
Show free variables of selection
|
|
|
|
|
|
|
|
|
|
*(go-channelpeers)*
|
|
|
|
|
|
|
|
|
|
Show send/receive corresponding to selected channel op
|
|
|
|
|
|
|
|
|
|
*(go-referrers)*
|
|
|
|
|
|
|
|
|
|
Show all refs to entity denoted by selected identifier
|
|
|
|
|
|
|
|
|
|
|
2015-01-18 12:58:28 +00:00
|
|
|
|
===============================================================================
|
|
|
|
|
TEXT OBJECTS *go-text-objects*
|
|
|
|
|
|
|
|
|
|
vim-go comes with several custom |text-objects| that can be used to operate
|
|
|
|
|
upon regions of text. vim-go currently defines the following text objects:
|
|
|
|
|
|
|
|
|
|
*go-v_af* *go-af*
|
|
|
|
|
af "a function", select contents from a function definition to the
|
|
|
|
|
closing bracket.
|
|
|
|
|
|
|
|
|
|
*go-v_if* *go-if*
|
|
|
|
|
if "inside a function", select contents of a function,
|
|
|
|
|
excluding the function definition and the closing bracket.
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
|
|
|
|
|
2015-02-24 10:45:22 +00:00
|
|
|
|
|
2014-10-31 21:30:24 +00:00
|
|
|
|
===============================================================================
|
|
|
|
|
SETTINGS *go-settings*
|
|
|
|
|
|
|
|
|
|
*'g:go_play_browser_command'*
|
|
|
|
|
|
|
|
|
|
Use this option to change the browser that is used to open the snippet url
|
|
|
|
|
posted to play.golang.org with |:GoPlay| or for the relevant documentation
|
|
|
|
|
used with |:GoDocBrowser|. By default it tries to find it automatically for
|
|
|
|
|
the current OS. >
|
|
|
|
|
|
|
|
|
|
let g:play_browser_command = ''
|
|
|
|
|
<
|
|
|
|
|
*'g:go_play_open_browser'*
|
|
|
|
|
|
|
|
|
|
Use this option to open browser after posting the snippet to play.golang.org
|
|
|
|
|
with |:GoPlay|. By default it's enabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_play_open_browser = 1
|
|
|
|
|
<
|
|
|
|
|
*'g:go_auto_type_info'*
|
|
|
|
|
|
|
|
|
|
Use this option to show the type info (|:GoInfo|) for the word under the cursor
|
|
|
|
|
automatically. Whenever the cursor changes the type info will be updated.
|
|
|
|
|
By default it's disabled >
|
|
|
|
|
|
|
|
|
|
let g:go_auto_type_info = 0
|
|
|
|
|
<
|
|
|
|
|
*'g:go_fmt_autosave'*
|
|
|
|
|
|
|
|
|
|
Use this option to auto |:GoFmt| on save. By default it's enabled >
|
|
|
|
|
|
|
|
|
|
let g:go_fmt_autosave = 1
|
|
|
|
|
<
|
|
|
|
|
*'g:go_fmt_command'*
|
|
|
|
|
|
|
|
|
|
Use this option to define which tool is used to gofmt. By default `gofmt` is
|
|
|
|
|
used >
|
|
|
|
|
|
|
|
|
|
let g:go_fmt_command = "gofmt"
|
|
|
|
|
<
|
|
|
|
|
*'g:go_fmt_options'*
|
|
|
|
|
|
|
|
|
|
Use this option to add additional options to the |g:go_fmt_command|. Default
|
|
|
|
|
is empty. >
|
|
|
|
|
|
|
|
|
|
let g:go_fmt_options = ''
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
*'g:go_fmt_fail_silently'*
|
|
|
|
|
|
|
|
|
|
Use this option to disable showing a quickfix window when |g:go_fmt_command|
|
|
|
|
|
fails. By default it's disabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_fmt_fail_silently = 0
|
|
|
|
|
<
|
2015-01-18 12:58:28 +00:00
|
|
|
|
|
|
|
|
|
*'g:go_fmt_experimental'*
|
|
|
|
|
|
|
|
|
|
Use this option to enable fmt's experimental mode. This experimental mode is
|
|
|
|
|
superior to the current mode as it fully saves the undo history, so undo/redo
|
|
|
|
|
doesn't break. However it's causing problems on some Vim versions. By default
|
|
|
|
|
it's disabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_fmt_experimental = 1
|
|
|
|
|
<
|
2014-10-31 21:30:24 +00:00
|
|
|
|
*'g:go_doc_keywordprg_enabled'*
|
|
|
|
|
|
|
|
|
|
Use this option to change the enable GoDoc to run on words under the cursor
|
|
|
|
|
with the default K , keywordprg shortcut. This shortcut is by default set to
|
|
|
|
|
use the program man. However in go using godoc is more idiomatic. Default is
|
|
|
|
|
enabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_doc_keywordprg_enabled = 1
|
|
|
|
|
<
|
|
|
|
|
*'g:go_def_mapping_enabled'*
|
|
|
|
|
|
|
|
|
|
Use this option to enabled/ disable the default mapping (`gd`) for GoDef
|
|
|
|
|
enabled. Disabling it allows you to map something else to the mapping `gd`.
|
|
|
|
|
Default is enabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_def_mapping_enabled = 1
|
|
|
|
|
<
|
|
|
|
|
*'g:go_doc_command'*
|
|
|
|
|
|
|
|
|
|
Use this option to define which tool is used to godoc. By default `godoc` is
|
|
|
|
|
used >
|
|
|
|
|
|
|
|
|
|
let g:go_doc_command = "godoc"
|
|
|
|
|
<
|
|
|
|
|
*'g:go_doc_options'*
|
|
|
|
|
|
|
|
|
|
Use this option to add additional options to the |g:go_doc_command|. Default
|
|
|
|
|
is empty. >
|
|
|
|
|
|
|
|
|
|
let g:go_doc_options = ''
|
|
|
|
|
|
|
|
|
|
< *'g:go_bin_path'*
|
|
|
|
|
|
2015-01-18 12:58:28 +00:00
|
|
|
|
Use this option to change default path for vim-go tools when using
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|GoInstallBinaries| and |GoUpdateBinaries|. If not set `$GOBIN` or
|
|
|
|
|
`$GOPATH/bin` is used. >
|
|
|
|
|
|
|
|
|
|
let g:go_bin_path = ""
|
|
|
|
|
<
|
|
|
|
|
*'g:go_snippet_engine'*
|
|
|
|
|
|
|
|
|
|
Use this option to define the default snippet engine. By default "ultisnips"
|
|
|
|
|
is used. Use "neosnippet" for neosnippet.vim: >
|
|
|
|
|
|
|
|
|
|
let g:go_snippet_engine = "ultisnips"
|
|
|
|
|
<
|
|
|
|
|
|
2015-02-24 10:45:22 +00:00
|
|
|
|
*'g:go_oracle_scope'*
|
|
|
|
|
|
|
|
|
|
Use this option to define the scope of the analysis to be passed for Oracle
|
|
|
|
|
related commands, such as |GoImplements|, |GoCallers|, etc.. By default it's
|
|
|
|
|
not set, so only the current packages go files are passed as scope. For more
|
|
|
|
|
info please have look at Oracle's User Manual:
|
|
|
|
|
https://docs.google.com/document/d/1SLk36YRjjMgKqe490mSRzOPYEDe0Y_WQNRv-EiFYUyw/view#heading=h.nwso96pj07q8
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
let g:go_oracle_scope = ''
|
|
|
|
|
<
|
|
|
|
|
|
2014-10-31 21:30:24 +00:00
|
|
|
|
*'g:go_highlight_array_whitespace_error'*
|
|
|
|
|
|
|
|
|
|
Highlights white space after "[]". >
|
|
|
|
|
|
|
|
|
|
let g:go_highlight_array_whitespace_error = 1
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
*'g:go_highlight_chan_whitespace_error'*
|
|
|
|
|
|
|
|
|
|
Highlights white space around the communications operator that don't follow
|
|
|
|
|
the standard style. >
|
|
|
|
|
|
|
|
|
|
let g:go_highlight_chan_whitespace_error = 1
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
*'g:go_highlight_extra_types'*
|
|
|
|
|
|
|
|
|
|
Highlights commonly used library types (io.Reader, etc.). >
|
|
|
|
|
|
|
|
|
|
let g:go_highlight_extra_types = 1
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
*'g:go_highlight_space_tab_error'*
|
|
|
|
|
|
|
|
|
|
Highlights instances of tabs following spaces. >
|
|
|
|
|
|
|
|
|
|
let g:go_highlight_space_tab_error = 1
|
|
|
|
|
<
|
|
|
|
|
*'g:go_highlight_trailing_whitespace_error'*
|
|
|
|
|
|
|
|
|
|
Highlights trailing white space. >
|
|
|
|
|
|
|
|
|
|
let g:go_highlight_trailing_whitespace_error = 1
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
*'g:go_highlight_operators'*
|
|
|
|
|
|
|
|
|
|
Highlights operators such as `:=` , `==`, `-=`, etc ...By default it's
|
|
|
|
|
disabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_highlight_operators = 0
|
|
|
|
|
<
|
|
|
|
|
*'g:go_highlight_functions'*
|
|
|
|
|
|
|
|
|
|
Highlights function names. By default it's disabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_highlight_functions = 0
|
|
|
|
|
<
|
|
|
|
|
*'g:go_highlight_methods'*
|
|
|
|
|
|
|
|
|
|
Highlights method names. By default it's disabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_highlight_methods = 0
|
|
|
|
|
<
|
|
|
|
|
*'g:go_highlight_structs'*
|
|
|
|
|
|
|
|
|
|
Highlights struct names. By default it's disabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_highlight_structs = 0
|
2015-02-04 10:43:54 +00:00
|
|
|
|
<
|
|
|
|
|
*'g:go_highlight_build_constraints'*
|
|
|
|
|
|
|
|
|
|
Highlights build constraints. By default it's disabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_highlight_build_constraints = 0
|
2014-10-31 21:30:24 +00:00
|
|
|
|
<
|
2015-01-18 12:58:28 +00:00
|
|
|
|
*'g:go_textobj_enabled'*
|
|
|
|
|
|
|
|
|
|
Adds custom text objects. By default it's enabled. >
|
|
|
|
|
|
|
|
|
|
let g:go_textobj_enabled = 1
|
|
|
|
|
|
2014-10-31 21:30:24 +00:00
|
|
|
|
===============================================================================
|
|
|
|
|
TROUBLESHOOTING *go-troubleshooting*
|
|
|
|
|
|
|
|
|
|
I'm using Fish shell but have some problems using Vim-go~
|
|
|
|
|
|
|
|
|
|
First environment variables in Fish are applied differently, it should be like:
|
|
|
|
|
>
|
|
|
|
|
set -x GOPATH /your/own/gopath
|
|
|
|
|
<
|
|
|
|
|
Second, Vim needs a POSIX compatible shell (more info here:
|
|
|
|
|
https://github.com/dag/vim-fish#teach-a-vim-to-fish). If you use Fish to open
|
|
|
|
|
vim, it will make certainx shell based commands fail (means vim-go will fail
|
|
|
|
|
too). To overcome this problem change the default shell by adding the
|
|
|
|
|
following into your .vimrc (on the top of the file):
|
|
|
|
|
>
|
|
|
|
|
if $SHELL =~ 'fish'
|
|
|
|
|
set shell='/bin/sh'
|
|
|
|
|
endif
|
|
|
|
|
<
|
|
|
|
|
or
|
|
|
|
|
>
|
|
|
|
|
set shell='/bin/sh'
|
|
|
|
|
>
|
|
|
|
|
|
2015-03-14 20:02:10 +00:00
|
|
|
|
I'm seeing weirds errors during installation of binaries with
|
|
|
|
|
GoInstallBinaries:
|
2014-10-31 21:30:24 +00:00
|
|
|
|
|
|
|
|
|
If you see errors like this:
|
|
|
|
|
>
|
|
|
|
|
Error installing code.google.com/p/go.tools/cmd/goimports:
|
|
|
|
|
Error installing code.google.com/p/rog-go/exp/cmd/godef:
|
|
|
|
|
<
|
|
|
|
|
that means your local Go setup is broken or the remote website is down. For
|
|
|
|
|
example sometimes code.google.com times out. To test, just execute a simple go
|
|
|
|
|
get:
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
go get code.google.com/p/go.tools/cmd/goimports
|
|
|
|
|
<
|
|
|
|
|
You'll see a more detailed error. If this works, vim-go will work too.
|
|
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
|
CREDITS *go-credits*
|
|
|
|
|
|
|
|
|
|
* Go Authors for offical vim plugins
|
|
|
|
|
* Gocode, Godef, Golint, Oracle, Goimports, Errcheck projects and authors of
|
|
|
|
|
those projects.
|
|
|
|
|
* Other vim-plugins, thanks for inspiration (vim-golang, go.vim, vim-gocode,
|
|
|
|
|
vim-godef)
|
|
|
|
|
* vim-go contributors: https://github.com/fatih/vim-go/graphs/contributors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vim:ft=help:et:ts=2:sw=2:sts=2:norl
|