Skip to content

Commit

Permalink
Add goimports feature, fixes #5 and #6
Browse files Browse the repository at this point in the history
  • Loading branch information
fatih committed Mar 25, 2014
1 parent da2d46c commit 4135bdb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ installed once at startup (can be disabled if path is provided, see

* Syntax highlighting
* Auto go fmt on save
* Automatically import packages with goimports
* Autocomplete with `<C-x><C-o>` (omnicomplete)

## Install
Expand All @@ -34,9 +35,15 @@ $ ./install.sh

```vimrc
" disable auto go fmt on save
let g:go_fmt_autosave=0
let g:go_fmt_autosave = 0
" disable goimports
let g:gofmt_command = "gofmt"
" change gocode path, disables automatic installing of goimports
let g:goimports_bin="~/your/custom/goimports/path"
" change gocode path, disables automatic installing of gocode
let g:gocode_bin="~/custom/path"
let g:gocode_bin="~/your/custom/gocode/path"
```
2 changes: 1 addition & 1 deletion ftplugin/go/fmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if !exists("g:go_fmt_commands")
endif

if !exists("g:gofmt_command")
let g:gofmt_command = "gofmt"
let g:gofmt_command = "goimports"
endif

if !exists('g:go_fmt_autosave')
Expand Down
14 changes: 13 additions & 1 deletion plugin/install.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ endif
if !filereadable(g:gocode_bin)
let import_path = "github.com/nsf/gocode"
let $GOBIN = expand("$HOME/.vim/bundle/go.vim/binary/gocode/")
echom "Installing gocode..."
echom "Installing gocode ..."
execute "silent !go get -u ".shellescape(import_path)
endif

if !exists("g:goimports_bin")
let g:goimports_bin = expand("$HOME/.vim/bundle/go.vim/binary/goimports/goimports")
endif

" install goimports if not available
if !filereadable(g:goimports_bin)
let import_path = "code.google.com/p/go.tools/cmd/goimports"
let $GOBIN = expand("$HOME/.vim/bundle/go.vim/binary/goimports/")
echom "Installing goimports ..."
execute "silent !go get -u ".shellescape(import_path)
endif

0 comments on commit 4135bdb

Please sign in to comment.