mirror of
				https://github.com/amix/vimrc
				synced 2025-10-31 06:33:35 +08:00 
			
		
		
		
	Updated plugins, also experimenting with a new font
The font is IBM Plex Mono: https://ibm.github.io/type/
This commit is contained in:
		| @ -21,70 +21,73 @@ CONTENTS                                                         *go-contents* | ||||
|   5. Text Objects.................................|go-text-objects| | ||||
|   6. Functions....................................|go-functions| | ||||
|   7. Settings.....................................|go-settings| | ||||
|   8. FAQ/Troubleshooting..........................|go-troubleshooting| | ||||
|   9. Development..................................|go-development| | ||||
|  10. Donation.....................................|go-donation| | ||||
|  11. Credits......................................|go-credits| | ||||
|   8. Syntax highlighting..........................|go-syntax| | ||||
|   9. FAQ/Troubleshooting..........................|go-troubleshooting| | ||||
|  10. Development..................................|go-development| | ||||
|  11. Donation.....................................|go-donation| | ||||
|  12. Credits......................................|go-credits| | ||||
|  | ||||
| ============================================================================== | ||||
| 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. | ||||
| Go (golang) support for Vim. vim-go comes with sensible predefined settings | ||||
| (e.g. automatic `gofmt` on save), has autocomplete, snippet support, improved | ||||
| syntax highlighting, go toolchain commands, etc. It is highly customizable, | ||||
| and individual features can be toggled easily. vim-go leverages a number of | ||||
| tools developed by the Go community to provide a seamless Vim experience. | ||||
|  | ||||
|   * Improved Syntax highlighting with items such as Functions, Operators, | ||||
|     Methods. | ||||
|   * Auto completion support via `gocode`. | ||||
|   * Better `gofmt` on save, which keeps cursor position and doesn't break your | ||||
|     undo history. | ||||
|   * Go to symbol/declaration with `:GoDef`. | ||||
|   * Look up documentation with `:GoDoc` inside Vim or open it in browser. | ||||
|   * Automatically import packages via `:GoImport` or plug it into autosave. | ||||
|   * Compile your package with `:GoBuild`, install them with `:GoInstall` or | ||||
|     test them with `:GoTest` (also supports running single tests with | ||||
|     `:GoTestFunc`). | ||||
|   * Quickly execute your current file/files with `:GoRun`. | ||||
|   * Automatic `GOPATH` detection based on the directory structure (e.g. `gb` | ||||
|     projects, `godep` vendored projects). | ||||
|   * Change or display `GOPATH` with `:GoPath`. | ||||
|   * Create a coverage profile and display annotated source code in to see | ||||
|     which functions are covered with `:GoCoverage`. | ||||
|   * Call `gometalinter` with `:GoMetaLinter`, which invokes all possible | ||||
|     linters (golint, vet, errcheck, deadcode, etc..) and shows the | ||||
|     warnings/errors. | ||||
|   * Lint your code with `:GoLint`. | ||||
|   * Run your code through `:GoVet` to catch static errors. | ||||
|   * Advanced source analysis tools utilizing guru, such as `:GoImplements`, | ||||
|     `:GoCallees`, and `:GoReferrers`. | ||||
|   * Precise type-safe renaming of identifiers with `:GoRename`. | ||||
|   * List all source files and dependencies. | ||||
|   * Unchecked error checking with `:GoErrCheck`. | ||||
|   * Compile your package with |:GoBuild|, install it with |:GoInstall| or | ||||
|     test it with |:GoTest|. Run a single tests with |:GoTestFunc|). | ||||
|   * Quickly execute your current file(s) with |:GoRun|. | ||||
|   * Improved syntax highlighting and folding. | ||||
|   * Completion support via `gocode`. | ||||
|   * `gofmt` or `goimports` 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|. | ||||
|   * Automatic `GOPATH` detection which works with `gb` and `godep`. Change or | ||||
|     display `GOPATH` with |:GoPath|. | ||||
|   * See which code is covered by tests with |:GoCoverage|. | ||||
|   * Add or remove tags on struct fields with |:GoAddTags| and |:GoRemoveTags|. | ||||
|   * Call `gometalinter` with |:GoMetaLinter| to invoke all possible linters | ||||
|     (`golint`, `vet`, `errcheck`, `deadcode`, etc.) and put the result in the | ||||
|     quickfix or location list. | ||||
|   * Lint your code with |:GoLint|, run your code through |:GoVet| to catch | ||||
|     static errors, or make sure errors are checked with |:GoErrCheck|. | ||||
|   * Advanced source analysis tools utilizing `guru`, such as |:GoImplements|, | ||||
|     |:GoCallees|, and |:GoReferrers|. | ||||
|   * Precise type-safe renaming of identifiers with |:GoRename|. | ||||
|   * Integrated and improved snippets, supporting `ultisnips` or `neosnippet`. | ||||
|   * Share your current code to [play.golang.org](http://play.golang.org) with | ||||
|     `:GoPlay` | ||||
|   * On-the-fly type information about the word under the cursor. Plug it into | ||||
|     your custom Vim function. | ||||
|   * Go asm formatting on save. | ||||
|   * Tagbar support to show tags of the source code in a sidebar with `gotags`. | ||||
|   * Custom vim text objects such as `a function` or `inner function`. | ||||
|   * A async launcher for the go command is implemented for neovim, fully async | ||||
|   * Share your current code to play.golang.org with |:GoPlay|. | ||||
|   * On-the-fly information about the word under the cursor. Plug it into your | ||||
|     custom Vim function. | ||||
|   * Text objects such as "a function" (|go-af|) or "inner function" (|go-if|). | ||||
|   * Most commands are run asynchronous in Neovim and Vim 8. Fully async | ||||
|     building and testing. | ||||
|   * Integrated with the neovim terminal, launch `:GoRun` and other go commands | ||||
|     in their own new terminal. | ||||
|   * Alternate between implementation and test code with `:GoAlternate`. | ||||
|   * Integrated with the Neovim terminal, launch |:GoRun| and other Go commands | ||||
|     in a terminal buffer. | ||||
|   * Switch between `file.go` and `file_test.go` code with |:GoAlternate|. | ||||
|   * Supports integration with the Tagbar and ctrlp.vim plugins. | ||||
|   * ...and more... | ||||
|  | ||||
| ============================================================================== | ||||
| INSTALL                                                           *go-install* | ||||
|  | ||||
| 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. | ||||
| The latest stable release, https://github.com/fatih/vim-go/releases/latest, 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 and should work with any of | ||||
| the major plugin managers. | ||||
|  | ||||
| For Pathogen or Vim |packages|, just clone the repo. For other plugin managers | ||||
| you may also need to add the lines to your vimrc to execute the plugin | ||||
| manager's install command. | ||||
|  | ||||
| *  Vim 8 |packages| | ||||
| > | ||||
|     git clone https://github.com/fatih/vim-go.git \ | ||||
|       ~/.vim/pack/plugins/start/vim-go | ||||
|  | ||||
| *  https://github.com/tpope/vim-pathogen > | ||||
|  | ||||
| @ -101,37 +104,51 @@ command. | ||||
| *  https://github.com/gmarik/vundle > | ||||
|  | ||||
|     Plugin 'fatih/vim-go' | ||||
|  | ||||
| *  Vim |packages| | ||||
| > | ||||
|     git clone https://github.com/fatih/vim-go.git \ | ||||
|       ~/.vim/pack/plugins/start/vim-go | ||||
| < | ||||
| *  Manual > | ||||
| *  Manual (not recommended) > | ||||
|  | ||||
|     Copy all of the files into your `~/.vim` directory | ||||
| < | ||||
| 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|, to | ||||
| `go get` all the required binaries. The binaries will be installed to $GOBIN | ||||
| or $GOPATH/bin (default: $HOME/go/bin). It requires `git`. | ||||
|  | ||||
| Please be sure all necessary binaries are installed (such as `gocode`, | ||||
| `godef`, `goimports`, etc.). You can easily install them with the included | ||||
| |: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. | ||||
| Depending on your installation method, you may have to generate the plugin's | ||||
| |:helptags| manually (e.g. `:helptags ALL`). | ||||
|  | ||||
| Autocompletion is enabled by default via 'omnifunc', which you can trigger | ||||
| with |i_CTRL-X_CTRL-O| (`<C-x><C-o>`). | ||||
|  | ||||
| Supported Go plugins~                                         *vim-go-plugins* | ||||
|  | ||||
| The following plugins are supported for use with vim-go: | ||||
|  | ||||
| * Real-time completion (Vim): | ||||
|   https://github.com/Shougo/neocomplete.vim | ||||
|  | ||||
| * Real-time completion (Neovim): | ||||
|   https://github.com/Shougo/deoplete.nvim and | ||||
|   https://github.com/zchee/deoplete-go | ||||
|  | ||||
| * Display source code navigation in a sidebar: | ||||
|   https://github.com/majutsushi/tagbar | ||||
|  | ||||
| * Snippets: | ||||
|   https://github.com/Shougo/neosnippet.vim or | ||||
|   https://github.com/SirVer/ultisnips | ||||
|  | ||||
| * Autocompletion is enabled by default via `<C-x><C-o>`, to get real-time | ||||
| completion (completion by type) install: | ||||
| https://github.com/Shougo/neocomplete.vim for Vim or | ||||
| https://github.com/Shougo/deoplete.nvim and | ||||
| https://github.com/zchee/deoplete-go for Neovim | ||||
| * To get displayed source code tag informations on a sidebar install | ||||
| https://github.com/majutsushi/tagbar. | ||||
| * For snippet feature install: | ||||
| https://github.com/Shougo/neosnippet.vim or | ||||
| https://github.com/SirVer/ultisnips. | ||||
| * For a better documentation viewer check out: | ||||
|   https://github.com/garyburd/go-explorer | ||||
|  | ||||
| * Integration with `delve` (Neovim only): | ||||
|   https://github.com/jodosha/vim-godebug | ||||
|  | ||||
| * Interactive |:GoDecls| and |:GoDeclsDir|: | ||||
|   https://github.com/ctrlpvim/ctrlp.vim or | ||||
|   https://github.com/junegunn/fzf.vim or | ||||
|   https://github.com/Shougo/unite.vim | ||||
|  | ||||
| ============================================================================== | ||||
| COMMANDS                                                         *go-commands* | ||||
|  | ||||
| @ -455,18 +472,24 @@ CTRL-t | ||||
|     Show dependencies for the current package. | ||||
|  | ||||
|                                                           *:GoInstallBinaries* | ||||
| :GoInstallBinaries | ||||
| :GoInstallBinaries [binaries] | ||||
|  | ||||
|     Download and Install all necessary Go tool binaries such as `godef`, | ||||
|     `goimports`, `gocode`, etc. under `g:go_bin_path`. Set | ||||
|     |'g:go_get_update'| to disable updating dependencies. | ||||
|     Download and install all necessary Go tool binaries such as `godef`, | ||||
|     `goimports`, `gocode`, etc. under |'g:go_bin_path'|. If [binaries] is | ||||
|     supplied, then only the specified binaries will be installed. The default | ||||
|     is to install everything. | ||||
|  | ||||
|     Set |'g:go_get_update'| to disable updating dependencies. | ||||
|  | ||||
|                                                            *:GoUpdateBinaries* | ||||
| :GoUpdateBinaries | ||||
| :GoUpdateBinaries [binaries] | ||||
|  | ||||
|     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. | ||||
|     Download and update previously installed Go tool binaries such as `godef`, | ||||
|     `goimports`, `gocode`, etc. under |'g:go_bin_path'|. If [binaries] is | ||||
|     supplied, then only the specified binaries will be updated. The default is | ||||
|     to update everything. | ||||
|  | ||||
|     Set |'g:go_get_update'| to disable updating dependencies. | ||||
|  | ||||
|                                                                *:GoImplements* | ||||
| :GoImplements | ||||
| @ -507,6 +530,8 @@ CTRL-t | ||||
|     Under the hood, the patterns are all joined to a comma-separated list and | ||||
|     passed to `guru`'s `-scope` flag. | ||||
|  | ||||
|     Also see |go-guru-scope|. | ||||
|  | ||||
|                                                                   *:GoCallees* | ||||
| :GoCallees | ||||
|  | ||||
| @ -541,13 +566,13 @@ CTRL-t | ||||
|                                                                  *:GoFreevars* | ||||
| :GoFreevars | ||||
|  | ||||
|     Enumerates the free variables of the selection. “Free variables” is a | ||||
|     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 | ||||
|     This information is useful when 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 | ||||
|     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. | ||||
|  | ||||
| @ -654,19 +679,35 @@ CTRL-t | ||||
|                                                                     *:GoDecls* | ||||
| :GoDecls [file] | ||||
|  | ||||
|     Only enabled if `ctrlp.vim` is installed. If run shows all function and | ||||
|     type declarations for the current file. If [file] is non empty it parses | ||||
|     the given file. | ||||
|     Show all function and type declarations for the current file. If | ||||
|     [file] is non empty it parses the given file. | ||||
|     Requires `ctrlp.vim` or `fzf`; it will autodetect the plugin if installed, | ||||
|     but you can use |'g:go_decls_mode'| to force using one or the other. | ||||
|     By default `type` and `func` declarations are shown. This can be changed | ||||
|     via |'g:go_decls_includes'|. | ||||
|     via |'g:go_decls_includes'|. Also see |unite-decls|. | ||||
|  | ||||
|                                                                  *:GoDeclsDir* | ||||
| :GoDeclsDir [dir] | ||||
|  | ||||
|     Only enabled if `ctrlp.vim` is installed. If run shows all function and | ||||
|     type declarations for the current directory. If [dir] is given it parses | ||||
|     the given directory. | ||||
|     Show all function and type declarations for the current directory. If | ||||
|     [dir] is given it parses the given directory. | ||||
|  | ||||
|                                                                  *unite-decls* | ||||
| :Unite decls[:file or dir] | ||||
|  | ||||
|     Only enabled if `unite.vim` is installed. Show declarations for all | ||||
|     functions and types on the current file or directory.  If [:file or dir] | ||||
|     is non empty, it parses the given one. | ||||
| > | ||||
|     " show declarations on the parent directory of the current file | ||||
|     :Unite decls | ||||
|  | ||||
|     " show declarations on the file | ||||
|     :Unite decls:foo/bar.go | ||||
|  | ||||
|     " show declarations on the directory | ||||
|     :Unite decls:foo | ||||
| < | ||||
|                                                                      *:GoImpl* | ||||
| :GoImpl [receiver] [interface] | ||||
|  | ||||
| @ -676,7 +717,7 @@ CTRL-t | ||||
|     receiver and the interface needs to be specified. Example usages: | ||||
| > | ||||
|       :GoImpl f *Foo io.Writer | ||||
|       :GoImpl T io.ReadWriteCloser | ||||
|       :GoImpl t Type io.ReadWriteCloser | ||||
| < | ||||
|                                                                   *:GoAddTags* | ||||
| :[range]GoAddTags [key],[option] [key1],[option] ... | ||||
| @ -766,12 +807,31 @@ CTRL-t | ||||
|         Surname: "Smith", | ||||
|       } | ||||
| < | ||||
|                                                                *:GoFillStruct* | ||||
| :GoFillStruct | ||||
|  | ||||
|     Use `fillstruct` to fill a struct literal with default values. Existing | ||||
|     values (if any) are preserved. The cursor must be on the struct you wish | ||||
|     to fill. | ||||
|  | ||||
|     For example: | ||||
| > | ||||
|       addr := net.Address{Name: "Ford Prefect"} | ||||
| < | ||||
|     Becomes: | ||||
| > | ||||
|       addr := net.Address{ | ||||
|         Name: "Ford Prefect", | ||||
|         Email: "", | ||||
|       } | ||||
| < | ||||
|  | ||||
| ============================================================================== | ||||
| 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` for the current package, create | ||||
| a mapping for the `(go-run)`: > | ||||
| For example, to create a mapping that calls `go run` for the current package, | ||||
| create a mapping for the `(go-run)`: > | ||||
|  | ||||
|   au FileType go nmap <leader>r <Plug>(go-run) | ||||
|  | ||||
| @ -1031,6 +1091,14 @@ into the statusline. This function is also used for |'g:go_auto_type_info'|. | ||||
| ============================================================================== | ||||
| SETTINGS                                                        *go-settings* | ||||
|  | ||||
|                                                     *'g:go_test_prepend_name'* | ||||
|  | ||||
| Prepend the name of the failed test to each test message generated by a failed | ||||
| test. By default it is disabled.  | ||||
| > | ||||
|   let g:go_test_prepend_name = 0  | ||||
| < | ||||
|  | ||||
|                                                          *'g:go_test_timeout'* | ||||
|  | ||||
| Use this option to change the test timeout of |:GoTest|. By default it is | ||||
| @ -1040,10 +1108,14 @@ set to 10 seconds . > | ||||
| < | ||||
|                                                  *'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. > | ||||
| Browser to use for |:GoPlay| or |:GoDocBrowser|. The url must be added with | ||||
| `%URL%`, and it's advisable to include `&` to make sure the shell returns. For | ||||
| example: | ||||
| > | ||||
|   let g:go_play_browser_command = 'firefox-developer %URL% &' | ||||
| < | ||||
|  | ||||
| By default it tries to find it automatically for the current OS. > | ||||
|  | ||||
|   let g:go_play_browser_command = '' | ||||
| < | ||||
| @ -1117,11 +1189,11 @@ used > | ||||
| Use this option to add additional options to the |'g:go_fmt_command'|. It's | ||||
| value type can be either a string or a dictionary. This is due backwards | ||||
| compatibility. The string version will be removed in the future so please use | ||||
| the dictionary version. Default is empty.  | ||||
| the dictionary version. Default is empty. | ||||
| > | ||||
|   let g:go_fmt_options = '' | ||||
|  | ||||
|   or  | ||||
|   or | ||||
|  | ||||
|   let g:go_fmt_options = {} | ||||
| < | ||||
| @ -1134,7 +1206,7 @@ The dictionary version allows you to define options for multiple binaries: | ||||
| < | ||||
|                                                     *'g:go_fmt_fail_silently'* | ||||
|  | ||||
| Use this option to disable showing a quickfix list when |'g:go_fmt_command'| | ||||
| Use this option to disable showing a location list when |'g:go_fmt_command'| | ||||
| fails. By default the location list is shown. > | ||||
|  | ||||
|   let g:go_fmt_fail_silently = 0 | ||||
| @ -1190,17 +1262,11 @@ mappings of |:GoDef|. By default it's disabled. > | ||||
| < | ||||
|                                                           *'g:go_doc_command'* | ||||
|  | ||||
| Use this option to define which tool is used to godoc. By default `godoc` is | ||||
| used > | ||||
| Command to use for |:GoDoc|; only used when invoked with a package name. The | ||||
| `gogetdoc` command is always used when |:GoDoc| is used on the identifier | ||||
| under the cursor (i.e. without argument or from |K|). > | ||||
|  | ||||
|   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 = '' | ||||
|   let g:go_doc_command = ["godoc"] | ||||
|  | ||||
| <                                                            *'g:go_bin_path'* | ||||
|  | ||||
| @ -1230,8 +1296,11 @@ Use this option to define the scope of the analysis to be passed for guru | ||||
| related commands, such as |:GoImplements|, |:GoCallers|, etc. You can change | ||||
| it on-the-fly with |:GoGuruScope|. The input should be a a list of package | ||||
| pattern. An example input might be: | ||||
| `["github.com/fatih/color","github.com/fatih/structs"]` By default it's not | ||||
| set, so the relevant commands defaults are being used. | ||||
| `["github.com/fatih/color","github.com/fatih/structs"]` | ||||
|  | ||||
| Also see |go-guru-scope|. | ||||
|  | ||||
| By default it's not set, so the relevant commands defaults are being used. | ||||
| > | ||||
|   let g:go_guru_scope = [] | ||||
| < | ||||
| @ -1243,94 +1312,6 @@ setting. A more useful way is to use |:GoBuildTags| to dynamically change or | ||||
| remove build tags. By default it's not set. | ||||
| > | ||||
|   let g:go_build_tags = '' | ||||
| < | ||||
|                                      *'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 doesn'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_types'* | ||||
|  | ||||
| Highlights struct and interface names. By default it's disabled. > | ||||
|  | ||||
|   let g:go_highlight_types = 0 | ||||
| < | ||||
|                                                      *'g:go_highlight_fields'* | ||||
|  | ||||
| Highlights field names. By default it's disabled. > | ||||
|  | ||||
|   let g:go_highlight_fields = 0 | ||||
| < | ||||
|                                           *'g:go_highlight_build_constraints'* | ||||
|  | ||||
| Highlights build constraints. By default it's disabled. > | ||||
|  | ||||
|   let g:go_highlight_build_constraints = 0 | ||||
| < | ||||
|                                           *'g:go_highlight_generate_tags'* | ||||
|  | ||||
| Highlights go:generate directives. By default it's disabled. > | ||||
|  | ||||
|   let g:go_highlight_generate_tags = 0 | ||||
| < | ||||
|                                           *'g:go_highlight_string_spellcheck'* | ||||
|  | ||||
| Use this option to highlight spelling errors in strings when |spell| is | ||||
| also enabled. By default it's enabled. > | ||||
|  | ||||
|   let g:go_highlight_string_spellcheck = 1 | ||||
| < | ||||
|                                              *'g:go_highlight_format_strings'* | ||||
|  | ||||
| Use this option to highlight printf-style operators inside string literals. | ||||
| By default it's enabled. > | ||||
|  | ||||
|   let g:go_highlight_format_strings = 1 | ||||
| < | ||||
|                                                     *'g:go_autodetect_gopath'* | ||||
|  | ||||
| @ -1339,9 +1320,9 @@ the tool `godep` which has his own dependencies via the `Godeps` folder. What | ||||
| this means is that all tools are now working with the newly modified GOPATH. | ||||
| So |:GoDef| for example jumps to the source inside the `Godeps` (vendored) | ||||
| source. Currently `godep` and `gb` is supported, in the near future more tool | ||||
| supports will be added. By default it's enabled. > | ||||
| supports will be added. By default it's disabled. > | ||||
|  | ||||
|   let g:go_autodetect_gopath = 1 | ||||
|   let g:go_autodetect_gopath = 0 | ||||
| < | ||||
|                                                       *'g:go_textobj_enabled'* | ||||
|  | ||||
| @ -1418,18 +1399,38 @@ explicitly overrides this behavior. For standard Vim behavior, set it to 10. | ||||
|                                                             *'g:go_list_type'* | ||||
|  | ||||
| Specifies the type of list to use for command outputs (such as errors from | ||||
| builds, results from static analysis commands, etc...). The default value | ||||
| (empty) will use the appropriate kind of list for the command that was called. | ||||
| Supported values are "", "quickfix", and "locationlist". > | ||||
|  | ||||
| builds, results from static analysis commands, etc...). The list type for | ||||
| specific commands can be overridden with |'g:go_list_type_commands'|. The | ||||
| default value (empty) will use the appropriate kind of list for the command | ||||
| that was called. Supported values are "", "quickfix", and "locationlist". | ||||
| > | ||||
|   let g:go_list_type = "" | ||||
| < | ||||
|  | ||||
|                                                    *'g:go_list_type_commands'* | ||||
|  | ||||
| Specifies the type of list to use for command outputs (such as errors from | ||||
| builds, results from static analysis commands, etc...). When an expected key | ||||
| is not present in the dictionary, |'g:go_list_type'| will be used instead. | ||||
| Supported keys are "GoBuild", "GoErrCheck", "GoFmt", "GoInstall", "GoLint", | ||||
| "GoMetaLinter", "GoModifyTags" (used for both :GoAddTags and :GoRemoveTags), | ||||
| "GoRename", "GoRun", and "GoTest".  Supported values for each command are | ||||
| "quickfix" and "locationlist". | ||||
| > | ||||
|   let g:go_list_type_commands = {} | ||||
| < | ||||
| As an example, the following settings will change all list types to | ||||
| `locationlist` except for `:GoBuild` where `quickfix` is used: | ||||
| > | ||||
|   let g:go_list_type = "locationlist" | ||||
|   let g:go_list_type_commands = {"GoBuild": "quickfix"} | ||||
| < | ||||
|  | ||||
|                                                        *'g:go_list_autoclose'* | ||||
|  | ||||
| Specifies whether the quickfix/location list should be closed automatically | ||||
| in the absence of errors.  The default value is 1. | ||||
| If you prefer to keep a long running error window open, you can disable  | ||||
| If you prefer to keep a long running error window open, you can disable | ||||
| this by setting the value to 0. | ||||
| > | ||||
|   let g:go_list_autoclose = 1 | ||||
| @ -1479,10 +1480,15 @@ By default it is set to edit. | ||||
| < | ||||
|                                                      *'g:go_gorename_prefill'* | ||||
|  | ||||
| Specifies whether |:GoRename| prefills the new identifier name with the | ||||
| word under the cursor. By default it is enabled. | ||||
| Expression to prefill the new identifier when using |:GoRename| without any | ||||
| arguments. Use an empty string if you don't want to prefill anything. By | ||||
| default it converts the identifier to camel case but preserves the | ||||
| capitalisation of the first letter to ensure that the exported state stays the | ||||
| same. | ||||
| > | ||||
|   let g:go_gorename_prefill = 1 | ||||
|   let g:go_gorename_prefill = 'expand("<cword>") =~# "^[A-Z]"' . | ||||
|         \ '? go#util#pascalcase(expand("<cword>"))' . | ||||
|         \ ': go#util#camelcase(expand("<cword>"))' | ||||
| < | ||||
|                                                      *'g:go_gocode_autobuild'* | ||||
|  | ||||
| @ -1559,11 +1565,20 @@ By default the template file specified by |'g:go_template_file'| is used. | ||||
| < | ||||
|                                                        *'g:go_decls_includes'* | ||||
|  | ||||
| Only useful if `ctrlp.vim` is installed. This sets which declarations to show | ||||
| for |:GoDecls|.  It is a Comma delimited list Possible options are: | ||||
| Only useful if `ctrlp.vim`, `unite.vim` or `fzf` are installed. This sets | ||||
| which declarations to show for |:GoDecls| (`ctrp.vim`) and |unite-decls| | ||||
| (`unite.vim`).  It is a Comma delimited list Possible options are: | ||||
| {func,type}.  The default is: > | ||||
|  | ||||
|       let g:go_decls_includes = 'func,type' | ||||
| < | ||||
|                                                        *'g:go_decls_mode'* | ||||
|  | ||||
| Define the tool to be used for |:GoDecls|. Valid options are `ctrlp.vim`, | ||||
| `fzf`, or an empty string; in which case it will try to autodetect either | ||||
| `ctrlp.vim` or `fzf`. | ||||
| > | ||||
|       let g:go_decls_mode = '' | ||||
| < | ||||
|                                                     *'g:go_echo_command_info'* | ||||
|  | ||||
| @ -1612,19 +1627,32 @@ By default "snakecase" is used. Current values are: ["snakecase", | ||||
| > | ||||
|       let g:go_addtags_transform = 'snakecase' | ||||
| < | ||||
|                                                         *'g:go_fold_enable'* | ||||
|  | ||||
| ============================================================================== | ||||
| SYNTAX HIGHLIGHTING                                 *ft-go-syntax* *go-syntax* | ||||
|  | ||||
| vim-go comes with an enhanced version of Vim's Go syntax highlighting. It | ||||
| comes with a number of features, most of which are disabled by default. | ||||
|  | ||||
| The recommended settings are the default values. If you're experiencing | ||||
| slowdowns in Go files and you enabled some of these options then try disabling | ||||
| them; some can be resource intensive. | ||||
|  | ||||
|                                                           *'g:go_fold_enable'* | ||||
|  | ||||
| Control syntax-based folding which takes effect when 'foldmethod' is set to | ||||
| `syntax`. | ||||
| You can enable specific fold regions by setting an array. Possible values are: | ||||
|  | ||||
| - "block"       `{` .. `}` blocks. | ||||
| - "import"      `import` block. | ||||
| - "varconst"    `var` and `const` blocks. | ||||
|  block                `{` .. `}` blocks. | ||||
|  import               `import` block. | ||||
|  varconst             `var` and `const` blocks. | ||||
|  package_comment      The package comment. | ||||
|  comment              Any comment that is not the package comment. | ||||
|  | ||||
| By default they're all enabled: | ||||
| By default all except "comment" are enabled: | ||||
| > | ||||
|   let g:go_fold_enable = ['block', 'import', 'varconst'] | ||||
|   let g:go_fold_enable = ['block', 'import', 'varconst', 'package_comment'] | ||||
| < | ||||
| Enable folding of only imports: | ||||
| > | ||||
| @ -1634,27 +1662,118 @@ Disable everything (same as not setting 'foldmethod' to `syntax`): | ||||
| > | ||||
|   let g:go_fold_enable = [] | ||||
| < | ||||
|                                      *'g:go_highlight_array_whitespace_error'* | ||||
|  | ||||
| Highlight white space after `[]`. > | ||||
|  | ||||
|   let g:go_highlight_array_whitespace_error = 0 | ||||
| < | ||||
|                                       *'g:go_highlight_chan_whitespace_error'* | ||||
|  | ||||
| Highlight white space around the receive operator (`<-`) that doesn't follow | ||||
| the standard style. > | ||||
|  | ||||
|   let g:go_highlight_chan_whitespace_error = 0 | ||||
| < | ||||
|                                                 *'g:go_highlight_extra_types'* | ||||
|  | ||||
| Highlight commonly used library types (`io.Reader`, etc.). > | ||||
|  | ||||
|   let g:go_highlight_extra_types = 0 | ||||
| < | ||||
|                                             *'g:go_highlight_space_tab_error'* | ||||
|  | ||||
| Highlight instances of tabs following spaces. > | ||||
|  | ||||
|   let g:go_highlight_space_tab_error = 0 | ||||
| < | ||||
|                                   *'g:go_highlight_trailing_whitespace_error'* | ||||
|  | ||||
| Highlight trailing white space. > | ||||
|  | ||||
|   let g:go_highlight_trailing_whitespace_error = 0 | ||||
| < | ||||
|                                                   *'g:go_highlight_operators'* | ||||
|  | ||||
| Highlight operators such as `:=` , `==`, `-=`, etc. | ||||
| > | ||||
|   let g:go_highlight_operators = 0 | ||||
| < | ||||
|                                                   *'g:go_highlight_functions'* | ||||
|  | ||||
| Highlight function names. | ||||
| > | ||||
|   let g:go_highlight_functions = 0 | ||||
| < | ||||
|                                                     *'g:go_highlight_methods'* | ||||
|  | ||||
| Highlight method names. | ||||
| > | ||||
|   let g:go_highlight_methods = 0 | ||||
| < | ||||
|                                                       *'g:go_highlight_types'* | ||||
|  | ||||
| Highlight struct and interface names. | ||||
| > | ||||
|   let g:go_highlight_types = 0 | ||||
| < | ||||
|                                                      *'g:go_highlight_fields'* | ||||
|  | ||||
| Highlight struct field names. | ||||
| > | ||||
|   let g:go_highlight_fields = 0 | ||||
| < | ||||
|                                           *'g:go_highlight_build_constraints'* | ||||
|  | ||||
| Highlights build constraints. | ||||
| > | ||||
|   let g:go_highlight_build_constraints = 0 | ||||
| < | ||||
|                                               *'g:go_highlight_generate_tags'* | ||||
|  | ||||
| Highlight go:generate directives. | ||||
| > | ||||
|   let g:go_highlight_generate_tags = 0 | ||||
| < | ||||
|                                           *'g:go_highlight_string_spellcheck'* | ||||
|  | ||||
| Highlight spelling errors in strings when |spell| is enabled. | ||||
| > | ||||
|   let g:go_highlight_string_spellcheck = 1 | ||||
| < | ||||
|                                              *'g:go_highlight_format_strings'* | ||||
|  | ||||
| Highlight printf-style formatting verbs inside string literals. | ||||
| > | ||||
|   let g:go_highlight_format_strings = 1 | ||||
| < | ||||
|                                       *'g:go_highlight_variable_declarations'* | ||||
|  | ||||
| Highlight variable names in variable declarations (`x` in ` x :=`). | ||||
| > | ||||
|   let g:go_highlight_variable_declarations = 0 | ||||
| < | ||||
|                                        *'g:go_highlight_variable_assignments'* | ||||
|  | ||||
| Highlight variable names in variable assignments (`x` in `x =`). | ||||
| > | ||||
|   let g:go_highlight_variable_assignments = 0 | ||||
| < | ||||
|  | ||||
| ============================================================================== | ||||
| DEVELOPMENT                                               *go-development* | ||||
|                                            *gohtmltmpl* *ft-gohtmltmpl-syntax* | ||||
|                                            *gotexttmpl* *ft-gotexttmpl-syntax* | ||||
| Go template syntax~ | ||||
|  | ||||
| vim-go supports test files written in VimL. Please check `autoload` folder for | ||||
| examples. If you add a new feature be sure you also include the `_test.vim` | ||||
| file next to the script. Test functions should be starting with `Test_`, | ||||
| example: | ||||
| > | ||||
|  function Test_run_fmt() | ||||
|    call assert_equal(expected, actual) | ||||
|    ... | ||||
|  endfunction | ||||
| < | ||||
| You can locally test it by running: | ||||
| > | ||||
|  make | ||||
| < | ||||
| This will run all tests and print either `PASS` or `FAIL` to indicate the | ||||
| final status of all tests. Additionally, each new pull request will trigger a | ||||
| new Travis-ci job. | ||||
| The `gotexttmpl` 'filetype' provides syntax highlighting and indentation for | ||||
| Go's `text/template` package. | ||||
|  | ||||
| The `gohtmltmpl` filetype is for use with the `html/template` package and is | ||||
| identical to `gotexttmpl` except that it will also load the standard `html` | ||||
| filetype. | ||||
|  | ||||
| The `gohtmltmpl` filetype is automatically set for `*.tmpl` files; the | ||||
| `gotexttmpl` is never automatically set and needs to be set manually. | ||||
|  | ||||
|  | ||||
| ============================================================================== | ||||
| @ -1681,14 +1800,45 @@ After opening vim, run `:echo $PATH`, the output must be your current `$PATH` | ||||
| plus `$GOPATH/bin` (the location where |:GoInstallBinaries| installed the | ||||
| binaries). | ||||
|  | ||||
|                                                                *go-guru-scope* | ||||
| What is the guru scope and how do I set it?~ | ||||
|  | ||||
| Many vim-go commands use the `guru` commandline tool to get information. Some | ||||
| `guru` commands require an expensive analysis of the source code. To still get | ||||
| a reasonable amount of performance `guru` limits this analysis to a selected | ||||
| list of packages. This is known as the "guru scope". | ||||
|  | ||||
| The default is to use the package the curent buffer belongs to, but this may | ||||
| not always be correct. For example for the file `guthub.com/user/pkg/a/a.go` | ||||
| the scope will be set to `github.com/user/pkg/a`, but you probably want | ||||
| `github.com/user/pkg` | ||||
|  | ||||
| Guessing what package(s) you do want is not easy so you may need to set this | ||||
| manually, usually from an |autocommand|: | ||||
| > | ||||
|   autocmd BufRead /home/martin/go/src/github.com/user/pkg/*.go | ||||
|         \ :GoGuruScope github.com/user/pkg | ||||
| < | ||||
|  | ||||
| If you have a lot of packages with the same prefix (`github.com/user`) you can | ||||
| use a single autocommand: | ||||
| > | ||||
|   autocmd BufRead /home/martin/go/src/*.go | ||||
|         \  let s:tmp = matchlist(expand('%:p'), | ||||
|             \ '/home/martin/go/src/\(github.com/user/[^/]\+\)') | ||||
|         \| if len(s:tmp) > 1 |  exe 'silent :GoGuruScope ' . s:tmp[1] | endif | ||||
|         \| unlet s:tmp | ||||
| < | ||||
| Also see |:GoGuruScope| and |'g:go_guru_scope'|. | ||||
|  | ||||
|  | ||||
| Vim becomes slow while editing Go files~ | ||||
|  | ||||
| Don't enable these options: | ||||
| > | ||||
|   let g:go_highlight_types = 0 | ||||
|   let g:go_highlight_operators = 0 | ||||
| < | ||||
| This is usually caused by `g:go_highlight_*` options. Try disabling them if | ||||
| you've enabled some of them. | ||||
|  | ||||
| Other common culprits are |'g:go_auto_sameids'| and |go#statusline#Show()|. | ||||
|  | ||||
|  | ||||
| I get errors when using GoInstallBinaries~ | ||||
|  | ||||
| @ -1745,6 +1895,13 @@ not appear.  To resolve this: | ||||
|  let g:go_list_type = "quickfix" | ||||
| < | ||||
|  | ||||
| How do I run focused ginkgo tests?~ | ||||
|  | ||||
| You must set this environment variable in your `.vimrc`: | ||||
| > | ||||
|   let $GINKGO_EDITOR_INTEGRATION = "true" | ||||
| < | ||||
|  | ||||
| Using with NeoVim~ | ||||
|  | ||||
| Note: Neovim currently is not a first class citizen for vim-go. You are free | ||||
| @ -1764,6 +1921,37 @@ By default new terminals are opened in a vertical split. To change it | ||||
|  let g:go_term_mode = "split" | ||||
| > | ||||
|  | ||||
| ============================================================================== | ||||
| DEVELOPMENT                                               *go-development* | ||||
|  | ||||
| vim-go supports test files written in VimScript; the way they're run is | ||||
| roughly similar to Go tests: | ||||
|  | ||||
| - A `*.vim` file has a corresponding `*_test.vim`. | ||||
| - All functions starting with `Test_` are run as test. | ||||
| - A test is considered to be "failed" if |v:errors| has any entries. You can | ||||
|   use one of the |test-functions| to set this, or append to it directly. | ||||
|  | ||||
| A simple example: | ||||
| > | ||||
|  function Test_run_fmt() | ||||
|    call assert_equal(expected, actual) | ||||
|    ... | ||||
|  endfunction | ||||
| < | ||||
| To run tests vim-go comes with three small helper scripts: | ||||
|  | ||||
|   `scripts/install-vim`   Install a pristine Vim to `/tmp/vim-go-test/`. | ||||
|   `scripts/run-vim`       Run a Vim version from `/tmp/vim-go-test/`. | ||||
|   `scripts/test`          Run all tests with a Vim from `/tmp/vim-go-test/`. | ||||
|  | ||||
| All scripts accept a Vim version as the first argument, which can be | ||||
| `vim-7.4`, `vim-8.0`, or `nvim`. You will need to install a Vim version with | ||||
| `install-vim` before you can use `run-vim` or `test`. | ||||
|  | ||||
| You can install and test all Vim versions by running `make`. | ||||
|  | ||||
|  | ||||
| ============================================================================== | ||||
| DONATION                                                         *go-donation* | ||||
|  | ||||
| @ -1773,7 +1961,7 @@ by being a patreon at: https://www.patreon.com/fatih | ||||
| By being a patron, you are enabling vim-go to grow and mature, helping me to | ||||
| invest in bug fixes, new documentation, and improving both current and future | ||||
| features. It's completely optional and is just a direct way to support | ||||
| Vim-go's ongoing development. Thanks! | ||||
| vim-go's ongoing development. Thanks! | ||||
|  | ||||
| Check it out: https://www.patreon.com/fatih | ||||
|  | ||||
| @ -1789,4 +1977,4 @@ CREDITS                                                         *go-credits* | ||||
| * vim-go contributors: https://github.com/fatih/vim-go/graphs/contributors. | ||||
|  | ||||
|  | ||||
| vim:ft=help:et:ts=2:sw=2:sts=2:norl | ||||
|  vim: ft=help tw=78 et ts=2 sw=2 sts=2 norl | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 amix
					amix