Skip to content

Commit

Permalink
Merge pull request farazdagi#8 from marinbek/master
Browse files Browse the repository at this point in the history
vim-go update
  • Loading branch information
farazdagi committed Mar 7, 2016
2 parents 874ece8 + 9403672 commit 5881815
Show file tree
Hide file tree
Showing 31 changed files with 1,888 additions and 536 deletions.
109 changes: 79 additions & 30 deletions bundle/pristine/vim-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ disabled/enabled easily.
* 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 it with `:GoInstall`
* Compile your package with `:GoBuild`, install it with `:GoInstall` or test
them with `:GoTest` (also supports running single tests via `:GoTestFunc`)
* Quickly execute your current file/files with `:GoRun`
* Run `:GoTest` and see any errors in the quickfix window
* Automatic `GOPATH` detection based on the directory structure (i.e. `godep`
vendored projects)
* Automatic `GOPATH` detection based on the directory structure (i.e. `gb`
projects, `godep` vendored projects)
* Change or display `GOPATH` with `:GoPath`
* Create a coverage profile and display annotated source code in browser 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 oracle, such as `:GoImplements`,
Expand All @@ -37,15 +39,23 @@ disabled/enabled easily.
* 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`
list.
* A async launcher for the go command is implemented for Neovim, fully async
building and testing (beta).
* Integrated with the Neovim terminal, launch `:GoRun` and other go commands
in their own new terminal. (beta)
* Alternate between implementation and test code with `:GoAlternate`

## 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 oriented vim plugins. For Pathogen just clone the repo. For other plugin managers
add the appropriate lines and execute the plugin's install command.
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 oriented vim plugins. For Pathogen just clone the repo. For other
plugin managers add the appropriate lines and execute the plugin's install
command.

* [Pathogen](https://github.com/tpope/vim-pathogen)
* `git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go`
Expand All @@ -60,22 +70,26 @@ 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 invoked, all necessary binaries will be
automatically downloaded and installed to your `$GOBIN` environment (if not set
it will use `$GOPATH/bin`). Note that this command requires `git` for fetching the individual Go
packages.
it will use `$GOPATH/bin`). Note that this command requires `git` for fetching
the individual Go packages. Additionally, use `:GoUpdateBinaries` to update the
installed binaries.

### Optional

* Autocompletion is enabled by default via `<C-x><C-o>`. To get real-time
completion (completion by type) install:
[YCM](https://github.com/Valloric/YouCompleteMe) or
[neocomplete](https://github.com/Shougo/neocomplete.vim).
[neocomplete](https://github.com/Shougo/neocomplete.vim) for Vim or
[deoplete](https://github.com/Shougo/deoplete.nvim) and
[deoplete-go](https://github.com/zchee/deoplete-go) for NeoVim
* To display source code tag information on a sidebar install
[tagbar](https://github.com/majutsushi/tagbar).
* For snippet features install:
[ultisnips](https://github.com/SirVer/ultisnips) or
[neosnippet](https://github.com/Shougo/neosnippet.vim).
* Screenshot color scheme is a slightly modified molokai: [fatih/molokai](https://github.com/fatih/molokai).
* For a better documentation viewer checkout: [go-explorer](https://github.com/garyburd/go-explorer).
[neosnippet](https://github.com/Shougo/neosnippet.vim) or
[ultisnips](https://github.com/SirVer/ultisnips).
* Screenshot color scheme is a slightly modified molokai:
[fatih/molokai](https://github.com/fatih/molokai).
* For a better documentation viewer checkout:
[go-explorer](https://github.com/garyburd/go-explorer).

## Usage

Expand All @@ -93,9 +107,9 @@ vim-go has several `<Plug>` mappings which can be used to create custom
mappings. Below are some examples you might find useful:

Run commands such as `go run` for the current file with `<leader>r` or `go
build` and `go test` for the current package with `<leader>b` and `<leader>t` respectively.
Display beautifully annotated source code to see which functions are covered
with `<leader>c`.
build` and `go test` for the current package with `<leader>b` and `<leader>t`
respectively. Display beautifully annotated source code to see which functions
are covered with `<leader>c`.

```vim
au FileType go nmap <leader>r <Plug>(go-run)
Expand Down Expand Up @@ -153,14 +167,16 @@ recommendations, you are free to create more advanced mappings or functions
based on `:he go-commands`.

## Settings
Below are some settings you might find useful. For the full list see `:he go-settings`.
Below are some settings you might find useful. For the full list see `:he
go-settings`.

By default syntax-highlighting for Functions, Methods and Structs is disabled.
To change it:
```vim
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_interfaces = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
```
Expand Down Expand Up @@ -197,25 +213,58 @@ let g:go_bin_path = expand("~/.gotools")
let g:go_bin_path = "/home/fatih/.mypath" "or give absolute path
```

### Using with Neovim (beta)

## More info
Note: Neovim currently is not a first class citizen for vim-go. You are free
to open bugs but I'm not going to look at them. Even though I'm using Neovim
myself, Neovim itself is still alpha. So vim-go might not work well as good as
in Vim. I'm happy to accept pull requests or very detailed bug reports.


Run `:GoRun` in a new tab, horizontal split or vertical split terminal

Check out the [Wiki](https://github.com/fatih/vim-go/wiki) page for more information. It includes [Screencasts](https://github.com/fatih/vim-go/wiki/Screencasts), an [FAQ
section](https://github.com/fatih/vim-go/wiki/FAQ-Troubleshooting), and many other [various pieces](https://github.com/fatih/vim-go/wiki) of information.
```vim
au FileType go nmap <leader>rt <Plug>(go-run-tab)
au FileType go nmap <Leader>rs <Plug>(go-run-split)
au FileType go nmap <Leader>rv <Plug>(go-run-vertical)
```

By default new terminals are opened in a vertical split. To change it

```vim
let g:go_term_mode = "split"
```

## Donations
By default the testing commands run asynchronously in the background and
display results with `go#jobcontrol#Statusline()`. To make them run in a new
terminal

Vim-go is an open source project that I'm working on in my free time. I'm
putting in a lot of time and thought to make it stable (fixing bugs, adding new
features, etc.). If you like vim-go and find it helpful, you might give me a
gift from some of the books (kindle) I have in my wish list:
```vim
let g:go_term_enabled = 1
```

### Using with Syntastic
Sometimes when using both `vim-go` and `syntastic` Vim will start lagging while
saving and opening files. The following fixes this:

```vim
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
```

## More info

[Amazon.com Fatih's Wish List](http://amzn.com/w/3RUTKZC0U30P6). Thanks!
Check out the [Wiki](https://github.com/fatih/vim-go/wiki) page for more
information. It includes
[Screencasts](https://github.com/fatih/vim-go/wiki/Screencasts), an [FAQ
section](https://github.com/fatih/vim-go/wiki/FAQ-Troubleshooting), and many
other [various pieces](https://github.com/fatih/vim-go/wiki) of information.

## Credits

* Go Authors for official vim plugins
* Gocode, Godef, Golint, Oracle, Goimports, Gotags, Errcheck projects and authors of those projects.
* Gocode, Godef, Golint, Oracle, Goimports, Gotags, Errcheck projects and
authors of those projects.
* Other vim-plugins, thanks for inspiration (vim-golang, go.vim, vim-gocode,
vim-godef)
* [Contributors](https://github.com/fatih/vim-go/graphs/contributors) of vim-go
Expand Down
30 changes: 30 additions & 0 deletions bundle/pristine/vim-go/autoload/go/alternate.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
" By default use edit (current buffer view) to switch
if !exists("g:go_alternate_mode")
let g:go_alternate_mode = "edit"
endif

" Test alternates between the implementation of code and the test code.
function! go#alternate#Switch(bang, cmd)
let l:file = go#alternate#Filename(fnameescape(expand("%")))
if !filereadable(l:file) && !bufexists(l:file) && !a:bang
redraws! | echon "vim-go: " | echohl ErrorMsg | echon "couldn't find ".file | echohl None
return
elseif empty(a:cmd)
execute ":" . g:go_alternate_mode . " " . file
else
execute ":" . a:cmd . " " . file
endif
endfunction

" Filename returns the name of the test file or implementation file
" depending on the arguments
function! go#alternate#Filename(path)
if empty(matchstr(a:path, "_test"))
let l:root = split(a:path, ".go$")[0]
let l:file = l:root . "_test.go"
else
let l:root = split(a:path, "_test.go$")[0]
let l:file = l:root . ".go"
endif
return l:file
endfunction
52 changes: 52 additions & 0 deletions bundle/pristine/vim-go/autoload/go/asmfmt.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
" asmfmt.vim: Vim command to format Go asm files with asmfmt
" (github.com/klauspost/asmfmt).
"
" This filetype plugin adds new commands for asm buffers:
"
" :Fmt
"
" Filter the current asm buffer through asmfmt.
" It tries to preserve cursor position and avoids
" replacing the buffer with stderr output.
"
" Options:
"
" g:go_asmfmt_autosave [default=1]
"
" Flag to automatically call :Fmt when file is saved.

let s:got_fmt_error = 0

" This is a trimmed-down version of the logic in fmt.vim.

function! go#asmfmt#Format()
" Save state.
let l:curw = winsaveview()

" Write the current buffer to a tempfile.
let l:tmpname = tempname()
call writefile(getline(1, '$'), l:tmpname)

" Run asmfmt.
let path = go#path#CheckBinPath("asmfmt")
if empty(path)
return
endif
let out = system(path . ' -w ' . l:tmpname)

" If there's no error, replace the current file with the output.
if v:shell_error == 0
" Remove undo point caused by BufWritePre.
try | silent undojoin | catch | endtry

" Replace the current file with the temp file; then reload the buffer.
let old_fileformat = &fileformat
call rename(l:tmpname, expand('%'))
silent edit!
let &fileformat = old_fileformat
let &syntax = &syntax
endif

" Restore the cursor/window positions.
call winrestview(l:curw)
endfunction
Loading

0 comments on commit 5881815

Please sign in to comment.