Skip to content

Commit

Permalink
Merge pull request #3209 from bhcleek/mapping/go-fmt
Browse files Browse the repository at this point in the history
mappings: add go-fmt
  • Loading branch information
bhcleek authored Apr 23, 2021
2 parents 3ec431e + c7d94a6 commit 283b8db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
36 changes: 19 additions & 17 deletions doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,9 @@ COMMANDS *go-commands*
*:GoImports*
:GoImports

Filter the current Go buffer through goimports (needs to be installed).
`goimports` automatically discards/add import path based on the code. Like
|:GoFmt|, It tries to preserve cursor position and avoids replacing the
buffer with stderr output.
Adjust imports using the setting of `g:go_imports_mode`. Like |:GoFmt|, It
tries to preserve cursor position and avoids replacing the buffer with
stderr output.

*:GoPlay*
:[range]GoPlay
Expand Down Expand Up @@ -935,7 +934,7 @@ documentation in the |go-commands| section. Available <Plug> keys are:

*(go-run)*

Calls `go run` for the current main package
Calls `go run` for the current main package.

*(go-run-tab)*

Expand All @@ -954,31 +953,31 @@ This option is neovim only.

*(go-build)*

Calls `go build` for the current package
Calls `go build` for the current package.

*(go-generate)*

Calls `go generate` for the current package
Calls `go generate` for the current package.

*(go-info)*

Shows type information for the word under the cursor
Shows type information for the word under the cursor.

*(go-install)*

Calls `go install` for the current package
Calls `go install` for the current package.

*(go-test)*

Calls `go test` for the current package
Calls `go test` for the current package.

*(go-test-func)*

Calls `go test -run '...'` for the test function immediate to cursor

*(go-test-compile)*

Calls `go test -c` for the current package
Calls `go test -c` for the current package.

*(go-coverage)*

Expand All @@ -987,35 +986,38 @@ coverage annotation.

*(go-coverage-clear)*

Clears the coverage annotation
Clears the coverage annotation.

*(go-coverage-toggle)*

Calls `go test -coverprofile-temp.out` for the current package and shows the
coverage annotation. If run again it acts as a toggle and clears the
annotation.

*(go-fmt)*

Format the current buffer.
*(go-imports)*

Calls `goimports` for the current package
Adjust imports for the current buffer.

*(go-lint)*

Calls `golint` for the current package
Calls `golint` for the current package.

*(go-vet)*

Calls `go vet` for the current package
Calls `go vet` for the current package.


*(go-files)*

Show source files that depends for the current package
Show source files that depends for the current package.


*(go-deps)*

Show dependencies for the current package
Show dependencies for the current package.

*(go-doc)*

Expand Down
2 changes: 1 addition & 1 deletion ftplugin/go/commands.vim
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ command! -nargs=* -range -complete=customlist,go#package#Complete GoDoc call go#
command! -nargs=* -range -complete=customlist,go#package#Complete GoDocBrowser call go#doc#OpenBrowser(<f-args>)

" -- fmt
command! -nargs=0 GoFmt call go#fmt#Format(-1)
command! -nargs=0 GoFmt call go#fmt#Format(0)
command! -nargs=0 GoFmtAutoSaveToggle call go#fmt#ToggleFmtAutoSave()
command! -nargs=0 GoImports call go#fmt#Format(1)

Expand Down
1 change: 1 addition & 0 deletions ftplugin/go/mappings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ nnoremap <silent> <Plug>(go-deps) :<C-u>call go#tool#Deps()<CR>
nnoremap <silent> <Plug>(go-info) :<C-u>call go#tool#Info(1)<CR>
nnoremap <silent> <Plug>(go-import) :<C-u>call go#import#SwitchImport(1, '', expand('<cword>'), '')<CR>
nnoremap <silent> <Plug>(go-imports) :<C-u>call go#fmt#Format(1)<CR>
nnoremap <silent> <Plug>(go-fmt) :<C-u>call go#fmt#Format(0)<CR>
nnoremap <silent> <Plug>(go-implements) :<C-u>call go#implements#Implements(-1)<CR>
nnoremap <silent> <Plug>(go-callees) :<C-u>call go#guru#Callees(-1)<CR>
Expand Down

0 comments on commit 283b8db

Please sign in to comment.