Skip to content

sethwklein/vim-go-fmt-on-save

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vim-go-fmt-on-save

Just the parts of vim-go that run goimports on save.

Warning

This will cause saving to blow away the redo list. Don't expect to be able to undo a bunch of times, save, and redo back to where you started.

Installation

  • If you wish to use goimports, install it.
  • Clone this repository and copy its contents into ~/.vim. That should put files in ~/.vim/{ftdetect,plugin,autoload/go}.
  • If goimports is slow for you (likely if you don't have an SSD), you may want to change go#fmt#Format(1) to go#fmt#Format(-1) (change 1 to -1) in plugin/go.vim. That will gofmt instead.

Creation

I created this by copying autoload/go/fmt.vim, autoload/go/tool.vim, and ftdetect/gofiletype.vim, and then taking the functions from IsWin through GetBinPath (in other words, the latter and all its dependencies) from plugin/go.vim. At the end of that file, I added just the if statement that installs the autocmd to call go#fmt#Format and changed the argument from -1 to 1.

Rationale

This may actually have been easier than figuring out how to turn off all the things in vim-go that I don't want (yet!)

About

Just the parts of vim-go that run goimports on save.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published